From 80f8722e2e0eb8975908d299763391ecc2679eb2 Mon Sep 17 00:00:00 2001 From: wjf-hs Date: Tue, 29 Apr 2025 16:49:54 +0800 Subject: [PATCH] =?UTF-8?q?append=E5=92=8Cpop=E5=87=BD=E6=95=B0=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E4=BA=86insert=E5=92=8Cdelete=EF=BC=8C=E7=90=86?= =?UTF-8?q?=E8=A7=A3=E8=B5=B7=E6=9D=A5=E6=9B=B4=E5=8A=A0=E7=9B=B4=E8=A7=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/list.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/list.c b/src/list.c index be8e3ad..ff5a330 100644 --- a/src/list.c +++ b/src/list.c @@ -76,60 +76,16 @@ static bool list_delete(struct _list* self, int index, void* obj) static bool list_append(struct _list* self, void* obj) { -#if 0 - assert(self != NULL); - assert(self->obj != NULL); - assert(obj != NULL); - - if (self->size(self) == self->_capacity) - { - int capacity = self->_capacity * self->_ratio; - void * obj_new = (void *)realloc(self->obj, capacity * self->_obj_size); - if (obj_new == NULL) - { - return false; - } - self->obj = obj_new; - self->_capacity = capacity; - } - uint32_t index = self->size(self); - uint32_t offset = index * self->_obj_size; - memmove((char*)self->obj + offset, obj, self->_obj_size); - - self->_size += 1; - return true; -#else return self->insert(self, (int)self->size(self), obj); -#endif } static bool list_pop(struct _list* self, void* obj) { -#if 0 - assert(self != NULL); - - if (self->empty(self)) - { - return false; - } - - uint32_t index = self->size(self) - 1; - uint32_t offset = index * self->_obj_size; - uint32_t offset1 = (index + 1) * self->_obj_size; - if (obj != NULL) - { - memmove(obj, (char*)self->obj + offset, self->_obj_size); - } - memmove((char*)self->obj + offset, (char*)self->obj + offset1, self->_obj_size); - self->_size -= 1; - return true; -#else if (self->empty(self)) { return false; } return self->delete(self, (int)self->size(self) - 1, obj); -#endif } static int list_index(struct _list* self, void* obj)