Lines Matching full:array
13 struct vmci_handle_arr *array; in vmci_handle_arr_create() local
22 array = kmalloc(struct_size(array, entries, capacity), GFP_ATOMIC); in vmci_handle_arr_create()
23 if (!array) in vmci_handle_arr_create()
26 array->capacity = capacity; in vmci_handle_arr_create()
27 array->max_capacity = max_capacity; in vmci_handle_arr_create()
28 array->size = 0; in vmci_handle_arr_create()
30 return array; in vmci_handle_arr_create()
33 void vmci_handle_arr_destroy(struct vmci_handle_arr *array) in vmci_handle_arr_destroy() argument
35 kfree(array); in vmci_handle_arr_destroy()
41 struct vmci_handle_arr *array = *array_ptr; in vmci_handle_arr_append_entry() local
43 if (unlikely(array->size >= array->capacity)) { in vmci_handle_arr_append_entry()
46 u32 capacity_bump = min(array->max_capacity - array->capacity, in vmci_handle_arr_append_entry()
47 array->capacity); in vmci_handle_arr_append_entry()
48 size_t new_size = struct_size(array, entries, in vmci_handle_arr_append_entry()
49 size_add(array->capacity, capacity_bump)); in vmci_handle_arr_append_entry()
51 if (array->size >= array->max_capacity) in vmci_handle_arr_append_entry()
54 new_array = krealloc(array, new_size, GFP_ATOMIC); in vmci_handle_arr_append_entry()
59 *array_ptr = array = new_array; in vmci_handle_arr_append_entry()
62 array->entries[array->size] = handle; in vmci_handle_arr_append_entry()
63 array->size++; in vmci_handle_arr_append_entry()
71 struct vmci_handle vmci_handle_arr_remove_entry(struct vmci_handle_arr *array, in vmci_handle_arr_remove_entry() argument
77 for (i = 0; i < array->size; i++) { in vmci_handle_arr_remove_entry()
78 if (vmci_handle_is_equal(array->entries[i], entry_handle)) { in vmci_handle_arr_remove_entry()
79 handle = array->entries[i]; in vmci_handle_arr_remove_entry()
80 array->size--; in vmci_handle_arr_remove_entry()
81 array->entries[i] = array->entries[array->size]; in vmci_handle_arr_remove_entry()
82 array->entries[array->size] = VMCI_INVALID_HANDLE; in vmci_handle_arr_remove_entry()
91 * Handle that was removed, VMCI_INVALID_HANDLE if array was empty.
93 struct vmci_handle vmci_handle_arr_remove_tail(struct vmci_handle_arr *array) in vmci_handle_arr_remove_tail() argument
97 if (array->size) { in vmci_handle_arr_remove_tail()
98 array->size--; in vmci_handle_arr_remove_tail()
99 handle = array->entries[array->size]; in vmci_handle_arr_remove_tail()
100 array->entries[array->size] = VMCI_INVALID_HANDLE; in vmci_handle_arr_remove_tail()
110 vmci_handle_arr_get_entry(const struct vmci_handle_arr *array, u32 index) in vmci_handle_arr_get_entry() argument
112 if (unlikely(index >= array->size)) in vmci_handle_arr_get_entry()
115 return array->entries[index]; in vmci_handle_arr_get_entry()
118 bool vmci_handle_arr_has_entry(const struct vmci_handle_arr *array, in vmci_handle_arr_has_entry() argument
123 for (i = 0; i < array->size; i++) in vmci_handle_arr_has_entry()
124 if (vmci_handle_is_equal(array->entries[i], entry_handle)) in vmci_handle_arr_has_entry()
131 * NULL if the array is empty. Otherwise, a pointer to the array
132 * of VMCI handles in the handle array.
134 struct vmci_handle *vmci_handle_arr_get_handles(struct vmci_handle_arr *array) in vmci_handle_arr_get_handles() argument
136 if (array->size) in vmci_handle_arr_get_handles()
137 return array->entries; in vmci_handle_arr_get_handles()