diff --git a/hehe_array_test b/hehe_array_test deleted file mode 100755 index a957692..0000000 Binary files a/hehe_array_test and /dev/null differ diff --git a/hehe_array_test.c b/hehe_array_test.c index 0c8ca2a..b9186eb 100644 --- a/hehe_array_test.c +++ b/hehe_array_test.c @@ -19,7 +19,7 @@ int main(void) { struct HeheArray *array2 = hehe_array_yoink(array, ARRAY2_START_INDEX, ARRAY2_LEN); if(array2 == NULL) return 69; for(i = 0; i < ARRAY2_LEN; i++) { - //printf("%d\n", *(int *)hehe_array_get(array2, i)); + printf("%d\n", *(int *)hehe_array_get(array2, i)); } puts("\n\n"); for(i = 0; i < ARRAY_LEN - ARRAY2_LEN; i++) { diff --git a/libhehe_array.h b/libhehe_array.h index 1736024..2878179 100644 --- a/libhehe_array.h +++ b/libhehe_array.h @@ -3,13 +3,6 @@ #ifndef HEHE_ARRAYLIB #define HEHE_ARRAYLIB -#define DEBUG -#ifdef DEBUG - -#include - -#endif - #include #include #include @@ -24,11 +17,11 @@ struct HeheArray { static void *hehe_alloc_array(size_t initial_len, size_t type_size) { if(initial_len == 0) initial_len = 1; struct HeheArray *array = malloc(sizeof(*array)); + array->len = initial_len; size_t max_len = 1; while(initial_len >>= 1) max_len <<= 1; array->type_size = type_size; - array->len = initial_len; array->max_len = max_len; array->content = malloc(max_len * type_size); memset(array->content, 0, max_len * type_size); @@ -77,17 +70,11 @@ static int hehe_array_pop(struct HeheArray *array, void *value) { } static struct HeheArray *hehe_array_yoink(struct HeheArray *array, size_t start_index, size_t len) { - puts("a"); if(start_index + len >= array->len) return NULL; - puts("b"); struct HeheArray *ret = hehe_alloc_array(len, array->type_size); - puts("c"); memcpy(ret->content, array->content + start_index * array->type_size, len * array->type_size); - puts("d"); memmove(array->content + start_index * array->type_size, array->content + (start_index + len) * array->type_size, (array->len - len - start_index) * array->type_size); - puts("e"); hehe_array_set_len(array, array->len - len); - puts("f"); return ret; }