version 1.1.1.1, 2013/10/14 10:32:47
|
version 1.1.1.2, 2014/06/15 20:20:06
|
Line 13 array *array_init(void) {
|
Line 13 array *array_init(void) {
|
array *a; |
array *a; |
|
|
a = calloc(1, sizeof(*a)); |
a = calloc(1, sizeof(*a)); |
assert(a); | force_assert(a); |
|
|
a->next_power_of_2 = 1; |
a->next_power_of_2 = 1; |
|
|
Line 24 array *array_init_array(array *src) {
|
Line 24 array *array_init_array(array *src) {
|
size_t i; |
size_t i; |
array *a = array_init(); |
array *a = array_init(); |
|
|
|
if (0 == src->size) return a; |
|
|
a->used = src->used; |
a->used = src->used; |
a->size = src->size; |
a->size = src->size; |
a->next_power_of_2 = src->next_power_of_2; |
a->next_power_of_2 = src->next_power_of_2; |
Line 72 void array_reset(array *a) {
|
Line 74 void array_reset(array *a) {
|
data_unset *array_pop(array *a) { |
data_unset *array_pop(array *a) { |
data_unset *du; |
data_unset *du; |
|
|
assert(a->used != 0); | force_assert(a->used != 0); |
|
|
a->used --; |
a->used --; |
du = a->data[a->used]; |
du = a->data[a->used]; |
Line 168 void array_set_key_value(array *hdrs, const char *key,
|
Line 170 void array_set_key_value(array *hdrs, const char *key,
|
data_unset *array_replace(array *a, data_unset *du) { |
data_unset *array_replace(array *a, data_unset *du) { |
int ndx; |
int ndx; |
|
|
|
force_assert(NULL != du); |
if (-1 == (ndx = array_get_index(a, du->key->ptr, du->key->used, NULL))) { |
if (-1 == (ndx = array_get_index(a, du->key->ptr, du->key->used, NULL))) { |
array_insert_unique(a, du); |
array_insert_unique(a, du); |
return NULL; |
return NULL; |
Line 211 int array_insert_unique(array *a, data_unset *str) {
|
Line 214 int array_insert_unique(array *a, data_unset *str) {
|
a->size = 16; |
a->size = 16; |
a->data = malloc(sizeof(*a->data) * a->size); |
a->data = malloc(sizeof(*a->data) * a->size); |
a->sorted = malloc(sizeof(*a->sorted) * a->size); |
a->sorted = malloc(sizeof(*a->sorted) * a->size); |
assert(a->data); | force_assert(a->data); |
assert(a->sorted); | force_assert(a->sorted); |
for (j = a->used; j < a->size; j++) a->data[j] = NULL; |
for (j = a->used; j < a->size; j++) a->data[j] = NULL; |
} else if (a->size == a->used) { |
} else if (a->size == a->used) { |
a->size += 16; |
a->size += 16; |
a->data = realloc(a->data, sizeof(*a->data) * a->size); |
a->data = realloc(a->data, sizeof(*a->data) * a->size); |
a->sorted = realloc(a->sorted, sizeof(*a->sorted) * a->size); |
a->sorted = realloc(a->sorted, sizeof(*a->sorted) * a->size); |
assert(a->data); | force_assert(a->data); |
assert(a->sorted); | force_assert(a->sorted); |
for (j = a->used; j < a->size; j++) a->data[j] = NULL; |
for (j = a->used; j < a->size; j++) a->data[j] = NULL; |
} |
} |
|
|