fixed the no work

This commit is contained in:
Seoxi Ryouko
2025-03-28 02:18:44 -05:00
parent a3099d90c5
commit f8cbe5c581
3 changed files with 2 additions and 15 deletions

View File

@ -3,13 +3,6 @@
#ifndef HEHE_ARRAYLIB
#define HEHE_ARRAYLIB
#define DEBUG
#ifdef DEBUG
#include <stdio.h>
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@ -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;
}