测试用例

This commit is contained in:
2026-08-29 11:39:28 +08:00
parent a0758766c5
commit 8fd65b0de0
19 changed files with 1723 additions and 432 deletions
+14 -1
View File
@@ -1,7 +1,8 @@
#include <c_ArrayQueue.h>
#include <c_Memory.h>
#define DEFAULT_INITIAL_CAPACITY 4
#define DEFAULT_INITIAL_CAPACITY 4
#define MIN_SHRINK_CAPACITY 4
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
@@ -72,6 +73,18 @@ c_err_t c_ArrayQueue_Pop(c_ArrayQueue_t* self, void* obj) {
}
self->size--;
if (self->size > 0 && self->size <= (self->capacity >> 2)) {
c_size_t new_capacity = self->capacity >> 1; // 容量减半
void* new_array = C_REALLOC(self->array, new_capacity * self->obj_size);
if (new_array) { // 如果 realloc 失败不影响原有数据安全,这里采用安全赋值
self->array = new_array;
self->capacity = new_capacity;
}
}
return C_ERR_OK;
}