Lines Matching full:array

50 ck_array_init(struct ck_array *array, unsigned int mode, struct ck_malloc *allocator, unsigned int …  in ck_array_init()  argument
66 array->n_entries = 0; in ck_array_init()
67 array->allocator = allocator; in ck_array_init()
68 array->active = active; in ck_array_init()
69 array->transaction = NULL; in ck_array_init()
74 ck_array_put(struct ck_array *array, void *value) in ck_array_put() argument
81 * modification of the array. in ck_array_put()
83 if (array->transaction == NULL) { in ck_array_put()
84 target = array->active; in ck_array_put()
86 if (array->n_entries == target->length) { in ck_array_put()
89 target = array->allocator->realloc(target, in ck_array_put()
90 sizeof(struct _ck_array) + sizeof(void *) * array->n_entries, in ck_array_put()
101 ck_pr_store_ptr(&array->active, target); in ck_array_put()
104 target->values[array->n_entries++] = value; in ck_array_put()
108 target = array->transaction; in ck_array_put()
109 if (array->n_entries == target->length) { in ck_array_put()
112 target = array->allocator->realloc(target, in ck_array_put()
113 sizeof(struct _ck_array) + sizeof(void *) * array->n_entries, in ck_array_put()
121 array->transaction = target; in ck_array_put()
124 target->values[array->n_entries++] = value; in ck_array_put()
129 ck_array_put_unique(struct ck_array *array, void *value) in ck_array_put_unique() argument
134 limit = array->n_entries; in ck_array_put_unique()
135 if (array->transaction != NULL) { in ck_array_put_unique()
136 v = array->transaction->values; in ck_array_put_unique()
138 v = array->active->values; in ck_array_put_unique()
146 return -!ck_array_put(array, value); in ck_array_put_unique()
150 ck_array_remove(struct ck_array *array, void *value) in ck_array_remove() argument
155 if (array->transaction != NULL) { in ck_array_remove()
156 target = array->transaction; in ck_array_remove()
158 for (i = 0; i < array->n_entries; i++) { in ck_array_remove()
160 target->values[i] = target->values[--array->n_entries]; in ck_array_remove()
168 target = array->active; in ck_array_remove()
170 for (i = 0; i < array->n_entries; i++) { in ck_array_remove()
175 if (i == array->n_entries) in ck_array_remove()
179 if (target->n_committed != array->n_entries) { in ck_array_remove()
180 ck_pr_store_ptr(&target->values[i], target->values[--array->n_entries]); in ck_array_remove()
187 * transactional array which will be applied upon commit time. in ck_array_remove()
189 target = ck_array_create(array->allocator, array->n_entries); in ck_array_remove()
193 memcpy(target->values, array->active->values, sizeof(void *) * array->n_entries); in ck_array_remove()
194 target->length = array->n_entries; in ck_array_remove()
195 target->n_committed = array->n_entries; in ck_array_remove()
196 target->values[i] = target->values[--array->n_entries]; in ck_array_remove()
198 array->transaction = target; in ck_array_remove()
203 ck_array_commit(ck_array_t *array) in ck_array_commit() argument
205 struct _ck_array *m = array->transaction; in ck_array_commit()
210 m->n_committed = array->n_entries; in ck_array_commit()
212 p = array->active; in ck_array_commit()
213 ck_pr_store_ptr(&array->active, m); in ck_array_commit()
214 array->allocator->free(p, sizeof(struct _ck_array) + in ck_array_commit()
216 array->transaction = NULL; in ck_array_commit()
222 ck_pr_store_uint(&array->active->n_committed, array->n_entries); in ck_array_commit()
227 ck_array_deinit(struct ck_array *array, bool defer) in ck_array_deinit() argument
230 array->allocator->free(array->active, in ck_array_deinit()
231 sizeof(struct _ck_array) + sizeof(void *) * array->active->length, defer); in ck_array_deinit()
233 if (array->transaction != NULL) { in ck_array_deinit()
234 array->allocator->free(array->transaction, in ck_array_deinit()
235 sizeof(struct _ck_array) + sizeof(void *) * array->transaction->length, defer); in ck_array_deinit()
238 array->transaction = array->active = NULL; in ck_array_deinit()