Lines Matching full:index
43 * Indexer - to find a structure given an index
45 * We store pointers using a double lookup and return an index to the
47 * the index are itself an index into an array of memory allocations.
51 * This allows us to adjust the number of pointers stored by the index
74 /* Index 0 is reserved */ in idx_grow()
89 int index; in idx_insert() local
91 if ((index = idx->free_list) == 0) { in idx_insert()
92 if ((index = idx_grow(idx)) <= 0) in idx_insert()
93 return index; in idx_insert()
96 entry = idx->array[idx_array_index(index)]; in idx_insert()
97 idx->free_list = entry[idx_entry_index(index)].next; in idx_insert()
98 entry[idx_entry_index(index)].item = item; in idx_insert()
99 return index; in idx_insert()
102 void *idx_remove(struct indexer *idx, int index) in idx_remove() argument
107 entry = idx->array[idx_array_index(index)]; in idx_remove()
108 item = entry[idx_entry_index(index)].item; in idx_remove()
109 entry[idx_entry_index(index)].next = idx->free_list; in idx_remove()
110 idx->free_list = index; in idx_remove()
114 void idx_replace(struct indexer *idx, int index, void *item) in idx_replace() argument
118 entry = idx->array[idx_array_index(index)]; in idx_replace()
119 entry[idx_entry_index(index)].item = item; in idx_replace()
123 static int idm_grow(struct index_map *idm, int index) in idm_grow() argument
125 idm->array[idx_array_index(index)] = calloc(IDX_ENTRY_SIZE, sizeof(void *)); in idm_grow()
126 if (!idm->array[idx_array_index(index)]) in idm_grow()
129 return index; in idm_grow()
136 int idm_set(struct index_map *idm, int index, void *item) in idm_set() argument
140 if (index > IDX_MAX_INDEX) { in idm_set()
145 if (!idm->array[idx_array_index(index)]) { in idm_set()
146 if (idm_grow(idm, index) < 0) in idm_set()
150 entry = idm->array[idx_array_index(index)]; in idm_set()
151 entry[idx_entry_index(index)] = item; in idm_set()
152 return index; in idm_set()
155 void *idm_clear(struct index_map *idm, int index) in idm_clear() argument
160 entry = idm->array[idx_array_index(index)]; in idm_clear()
161 item = entry[idx_entry_index(index)]; in idm_clear()
162 entry[idx_entry_index(index)] = NULL; in idm_clear()