Lines Matching refs:vector
30 struct vector *vector, in dal_vector_construct() argument
35 vector->container = NULL; in dal_vector_construct()
43 vector->container = kcalloc(capacity, struct_size, GFP_KERNEL); in dal_vector_construct()
44 if (vector->container == NULL) in dal_vector_construct()
46 vector->capacity = capacity; in dal_vector_construct()
47 vector->struct_size = struct_size; in dal_vector_construct()
48 vector->count = 0; in dal_vector_construct()
49 vector->ctx = ctx; in dal_vector_construct()
53 static bool dal_vector_presized_costruct(struct vector *vector, in dal_vector_presized_costruct() argument
61 vector->container = NULL; in dal_vector_presized_costruct()
69 vector->container = kcalloc(count, struct_size, GFP_KERNEL); in dal_vector_presized_costruct()
71 if (vector->container == NULL) in dal_vector_presized_costruct()
80 vector->container + i * struct_size, in dal_vector_presized_costruct()
85 vector->capacity = count; in dal_vector_presized_costruct()
86 vector->struct_size = struct_size; in dal_vector_presized_costruct()
87 vector->count = count; in dal_vector_presized_costruct()
91 struct vector *dal_vector_presized_create( in dal_vector_presized_create()
97 struct vector *vector = kzalloc(sizeof(struct vector), GFP_KERNEL); in dal_vector_presized_create() local
99 if (vector == NULL) in dal_vector_presized_create()
103 vector, ctx, size, initial_value, struct_size)) in dal_vector_presized_create()
104 return vector; in dal_vector_presized_create()
107 kfree(vector); in dal_vector_presized_create()
111 struct vector *dal_vector_create( in dal_vector_create()
116 struct vector *vector = kzalloc(sizeof(struct vector), GFP_KERNEL); in dal_vector_create() local
118 if (vector == NULL) in dal_vector_create()
121 if (dal_vector_construct(vector, ctx, capacity, struct_size)) in dal_vector_create()
122 return vector; in dal_vector_create()
125 kfree(vector); in dal_vector_create()
130 struct vector *vector) in dal_vector_destruct() argument
132 kfree(vector->container); in dal_vector_destruct()
133 vector->count = 0; in dal_vector_destruct()
134 vector->capacity = 0; in dal_vector_destruct()
138 struct vector **vector) in dal_vector_destroy() argument
140 if (vector == NULL || *vector == NULL) in dal_vector_destroy()
142 dal_vector_destruct(*vector); in dal_vector_destroy()
143 kfree(*vector); in dal_vector_destroy()
144 *vector = NULL; in dal_vector_destroy()
148 const struct vector *vector) in dal_vector_get_count() argument
150 return vector->count; in dal_vector_get_count()
154 const struct vector *vector, in dal_vector_at_index() argument
157 if (vector->container == NULL || index >= vector->count) in dal_vector_at_index()
159 return vector->container + (index * vector->struct_size); in dal_vector_at_index()
163 struct vector *vector, in dal_vector_remove_at_index() argument
166 if (index >= vector->count) in dal_vector_remove_at_index()
169 if (index != vector->count - 1) in dal_vector_remove_at_index()
171 vector->container + (index * vector->struct_size), in dal_vector_remove_at_index()
172 vector->container + ((index + 1) * vector->struct_size), in dal_vector_remove_at_index()
173 (vector->count - index - 1) * vector->struct_size); in dal_vector_remove_at_index()
174 vector->count -= 1; in dal_vector_remove_at_index()
180 const struct vector *vector, in dal_vector_set_at_index() argument
184 void *where = dal_vector_at_index(vector, index); in dal_vector_set_at_index()
193 vector->struct_size); in dal_vector_set_at_index()
203 struct vector *vector, in dal_vector_insert_at() argument
209 if (vector->count == vector->capacity) { in dal_vector_insert_at()
211 vector, in dal_vector_insert_at()
212 calc_increased_capacity(vector->capacity))) in dal_vector_insert_at()
216 insert_address = vector->container + (vector->struct_size * position); in dal_vector_insert_at()
218 if (vector->count && position < vector->count) in dal_vector_insert_at()
220 insert_address + vector->struct_size, in dal_vector_insert_at()
222 vector->struct_size * (vector->count - position)); in dal_vector_insert_at()
227 vector->struct_size); in dal_vector_insert_at()
229 vector->count++; in dal_vector_insert_at()
235 struct vector *vector, in dal_vector_append() argument
238 return dal_vector_insert_at(vector, item, vector->count); in dal_vector_append()
241 struct vector *dal_vector_clone( in dal_vector_clone()
242 const struct vector *vector) in dal_vector_clone() argument
244 struct vector *vec_cloned; in dal_vector_clone()
248 count = dal_vector_get_count(vector); in dal_vector_clone()
254 vector->ctx, in dal_vector_clone()
255 vector->capacity, in dal_vector_clone()
256 vector->struct_size); in dal_vector_clone()
263 vec_cloned = dal_vector_presized_create(vector->ctx, count, in dal_vector_clone()
265 vector->struct_size); in dal_vector_clone()
273 memmove(vec_cloned->container, vector->container, in dal_vector_clone()
279 uint32_t dal_vector_capacity(const struct vector *vector) in dal_vector_capacity() argument
281 return vector->capacity; in dal_vector_capacity()
284 bool dal_vector_reserve(struct vector *vector, uint32_t capacity) in dal_vector_reserve() argument
288 if (capacity <= vector->capacity) in dal_vector_reserve()
291 new_container = krealloc(vector->container, in dal_vector_reserve()
292 capacity * vector->struct_size, GFP_KERNEL); in dal_vector_reserve()
295 vector->container = new_container; in dal_vector_reserve()
296 vector->capacity = capacity; in dal_vector_reserve()
303 void dal_vector_clear(struct vector *vector) in dal_vector_clear() argument
305 vector->count = 0; in dal_vector_clear()