38 while (vec->
alloc < res)
42 vec->
data = malloc(vec->
alloc *
sizeof(
void*));
58 for (i = 0; i < vec->
len; i++)
79 memset(vec, 0,
sizeof(*vec));
85 size_t new_alloc = vec->
alloc;
86 while (new_alloc < min_sz)
89 if (vec->
alloc == new_alloc)
92 void* new_data = realloc(vec->
data, new_alloc *
sizeof(
void*));
97 vec->
alloc = new_alloc;
103 if (vec && vec->
len) {
105 for (i = 0; i < vec->
len; i++)
106 if (vec->
data[i] == data)
126 if (!vec || ((pos + len) > vec->
len))
130 unsigned int i, count;
131 for (i = pos, count = 0; count <
len; i++, count++)
135 memmove(&vec->
data[pos], &vec->
data[pos + len], (vec->
len - pos - len) *
sizeof(
void*));
159 if (newsz == vec->
len)
163 else if (newsz < vec->
len) {
164 size_t del_count = vec->
len - newsz;
166 for (i = (vec->
len - del_count); i < vec->len; i++) {
181 for (i = vec->
len; i < newsz; i++)
vector * vector_new(size_t res, void(*free_f)(void *))
static btc_bool vector_grow(vector *vec, size_t min_sz)
void vector_remove_range(vector *vec, size_t pos, size_t len)
ssize_t vector_find(vector *vec, void *data)
static void vector_free_data(vector *vec)
void(* elem_free_f)(void *)
btc_bool vector_add(vector *vec, void *data)
btc_bool vector_remove(vector *vec, void *data)
void vector_free(vector *vec, btc_bool free_array)
btc_bool vector_resize(vector *vec, size_t newsz)
void vector_remove_idx(vector *vec, size_t pos)