Lines Matching +full:array +full:- +full:union
2 * Copyright © 2008-2011 Kristian Høgsberg
34 #include "wayland-util.h"
35 #include "wayland-private.h"
40 list->prev = list; in wl_list_init()
41 list->next = list; in wl_list_init()
47 elm->prev = list; in wl_list_insert()
48 elm->next = list->next; in wl_list_insert()
49 list->next = elm; in wl_list_insert()
50 elm->next->prev = elm; in wl_list_insert()
56 elm->prev->next = elm->next; in wl_list_remove()
57 elm->next->prev = elm->prev; in wl_list_remove()
58 elm->next = NULL; in wl_list_remove()
59 elm->prev = NULL; in wl_list_remove()
69 e = list->next; in wl_list_length()
71 e = e->next; in wl_list_length()
81 return list->next == list; in wl_list_empty()
90 other->next->prev = list; in wl_list_insert_list()
91 other->prev->next = list->next; in wl_list_insert_list()
92 list->next->prev = other->prev; in wl_list_insert_list()
93 list->next = other->next; in wl_list_insert_list()
97 wl_array_init(struct wl_array *array) in wl_array_init() argument
99 memset(array, 0, sizeof *array); in wl_array_init()
103 wl_array_release(struct wl_array *array) in wl_array_release() argument
105 free(array->data); in wl_array_release()
106 array->data = WL_ARRAY_POISON_PTR; in wl_array_release()
110 wl_array_add(struct wl_array *array, size_t size) in wl_array_add() argument
115 if (array->alloc > 0) in wl_array_add()
116 alloc = array->alloc; in wl_array_add()
120 while (alloc < array->size + size) in wl_array_add()
123 if (array->alloc < alloc) { in wl_array_add()
124 if (array->alloc > 0) in wl_array_add()
125 data = realloc(array->data, alloc); in wl_array_add()
131 array->data = data; in wl_array_add()
132 array->alloc = alloc; in wl_array_add()
135 p = (char *)array->data + array->size; in wl_array_add()
136 array->size += size; in wl_array_add()
142 wl_array_copy(struct wl_array *array, struct wl_array *source) in wl_array_copy() argument
144 if (array->size < source->size) { in wl_array_copy()
145 if (!wl_array_add(array, source->size - array->size)) in wl_array_copy()
146 return -1; in wl_array_copy()
148 array->size = source->size; in wl_array_copy()
151 if (source->size > 0) in wl_array_copy()
152 memcpy(array->data, source->data, source->size); in wl_array_copy()
169 return a == b || strcmp(a->name, b->name) == 0; in wl_interface_equal()
172 union map_entry {
185 map->side = side; in wl_map_init()
191 wl_array_release(&map->client_entries); in wl_map_release()
192 wl_array_release(&map->server_entries); in wl_map_release()
198 union map_entry *start, *entry; in wl_map_insert_new()
203 if (map->side == WL_MAP_CLIENT_SIDE) { in wl_map_insert_new()
204 entries = &map->client_entries; in wl_map_insert_new()
207 entries = &map->server_entries; in wl_map_insert_new()
211 if (map->free_list) { in wl_map_insert_new()
212 start = entries->data; in wl_map_insert_new()
213 entry = &start[map->free_list >> 1]; in wl_map_insert_new()
214 map->free_list = entry->next; in wl_map_insert_new()
219 start = entries->data; in wl_map_insert_new()
224 * pro-active about trying to avoid this allocation, but in wl_map_insert_new()
227 * the whole array either way. in wl_map_insert_new()
229 count = entry - start; in wl_map_insert_new()
231 /* entry->data is freshly malloced garbage, so we'd in wl_map_insert_new()
234 entry->data = NULL; in wl_map_insert_new()
238 entry->data = data; in wl_map_insert_new()
239 entry->next |= (flags & 0x1) << 1; in wl_map_insert_new()
247 union map_entry *start; in wl_map_insert_at()
252 entries = &map->client_entries; in wl_map_insert_at()
254 entries = &map->server_entries; in wl_map_insert_at()
255 i -= WL_SERVER_ID_START; in wl_map_insert_at()
260 return -1; in wl_map_insert_at()
263 count = entries->size / sizeof *start; in wl_map_insert_at()
266 return -1; in wl_map_insert_at()
271 return -1; in wl_map_insert_at()
274 start = entries->data; in wl_map_insert_at()
284 union map_entry *start; in wl_map_reserve_new()
289 if (map->side == WL_MAP_CLIENT_SIDE) { in wl_map_reserve_new()
291 return -1; in wl_map_reserve_new()
294 entries = &map->client_entries; in wl_map_reserve_new()
296 if (map->side == WL_MAP_SERVER_SIDE) { in wl_map_reserve_new()
298 return -1; in wl_map_reserve_new()
301 entries = &map->server_entries; in wl_map_reserve_new()
302 i -= WL_SERVER_ID_START; in wl_map_reserve_new()
307 return -1; in wl_map_reserve_new()
310 count = entries->size / sizeof *start; in wl_map_reserve_new()
313 return -1; in wl_map_reserve_new()
318 return -1; in wl_map_reserve_new()
320 start = entries->data; in wl_map_reserve_new()
323 start = entries->data; in wl_map_reserve_new()
326 return -1; in wl_map_reserve_new()
336 union map_entry *start; in wl_map_remove()
340 if (map->side == WL_MAP_SERVER_SIDE) in wl_map_remove()
343 entries = &map->client_entries; in wl_map_remove()
345 if (map->side == WL_MAP_CLIENT_SIDE) in wl_map_remove()
348 entries = &map->server_entries; in wl_map_remove()
349 i -= WL_SERVER_ID_START; in wl_map_remove()
352 start = entries->data; in wl_map_remove()
353 start[i].next = map->free_list; in wl_map_remove()
354 map->free_list = (i << 1) | 1; in wl_map_remove()
360 union map_entry *start; in wl_map_lookup()
365 entries = &map->client_entries; in wl_map_lookup()
367 entries = &map->server_entries; in wl_map_lookup()
368 i -= WL_SERVER_ID_START; in wl_map_lookup()
371 start = entries->data; in wl_map_lookup()
372 count = entries->size / sizeof *start; in wl_map_lookup()
383 union map_entry *start; in wl_map_lookup_flags()
388 entries = &map->client_entries; in wl_map_lookup_flags()
390 entries = &map->server_entries; in wl_map_lookup_flags()
391 i -= WL_SERVER_ID_START; in wl_map_lookup_flags()
394 start = entries->data; in wl_map_lookup_flags()
395 count = entries->size / sizeof *start; in wl_map_lookup_flags()
407 union map_entry entry, *start; in for_each_helper()
410 start = (union map_entry *) entries->data; in for_each_helper()
411 count = entries->size / sizeof(union map_entry); in for_each_helper()
430 ret = for_each_helper(&map->client_entries, func, data); in wl_map_for_each()
432 for_each_helper(&map->server_entries, func, data); in wl_map_for_each()