proxy->refcount = 1;
pthread_mutex_lock(&display->mutex);
- proxy->object.id = wl_map_insert_new(&display->objects,
- WL_MAP_CLIENT_SIDE, proxy);
+ proxy->object.id = wl_map_insert_new(&display->objects, proxy);
pthread_mutex_unlock(&display->mutex);
return proxy;
memset(display, 0, sizeof *display);
display->fd = fd;
- wl_map_init(&display->objects);
+ wl_map_init(&display->objects, WL_MAP_CLIENT_SIDE);
wl_event_queue_init(&display->queue, display);
wl_list_init(&display->event_queue_list);
pthread_mutex_init(&display->mutex, NULL);
- wl_map_insert_new(&display->objects, WL_MAP_CLIENT_SIDE, NULL);
+ wl_map_insert_new(&display->objects, NULL);
display->proxy.object.interface = &wl_display_interface;
display->proxy.object.id =
- wl_map_insert_new(&display->objects,
- WL_MAP_CLIENT_SIDE, display);
+ wl_map_insert_new(&display->objects, display);
display->proxy.display = display;
display->proxy.object.implementation = (void(**)(void)) &display_listener;
display->proxy.user_data = display;
struct wl_map {
struct wl_array client_entries;
struct wl_array server_entries;
+ uint32_t side;
uint32_t free_list;
};
typedef void (*wl_iterator_func_t)(void *element, void *data);
-void wl_map_init(struct wl_map *map);
+void wl_map_init(struct wl_map *map, uint32_t side);
void wl_map_release(struct wl_map *map);
-uint32_t wl_map_insert_new(struct wl_map *map, uint32_t side, void *data);
+uint32_t wl_map_insert_new(struct wl_map *map, void *data);
int wl_map_insert_at(struct wl_map *map, uint32_t i, void *data);
int wl_map_reserve_new(struct wl_map *map, uint32_t i);
void wl_map_remove(struct wl_map *map, uint32_t i);
if (client->connection == NULL)
goto err_source;
- wl_map_init(&client->objects);
+ wl_map_init(&client->objects, WL_MAP_SERVER_SIDE);
if (wl_map_insert_at(&client->objects, 0, NULL) < 0)
goto err_map;
{
if (resource->object.id == 0) {
resource->object.id =
- wl_map_insert_new(&client->objects,
- WL_MAP_SERVER_SIDE, resource);
+ wl_map_insert_new(&client->objects, resource);
} else if (wl_map_insert_at(&client->objects,
resource->object.id, resource) < 0) {
wl_resource_post_error(client->display_resource,
{
uint32_t id;
- id = wl_map_insert_new(&client->objects, WL_MAP_SERVER_SIDE, NULL);
+ id = wl_map_insert_new(&client->objects, NULL);
return wl_client_add_object(client,
interface, implementation, id, data);
};
WL_EXPORT void
-wl_map_init(struct wl_map *map)
+wl_map_init(struct wl_map *map, uint32_t side)
{
memset(map, 0, sizeof *map);
+ map->side = side;
}
WL_EXPORT void
}
WL_EXPORT uint32_t
-wl_map_insert_new(struct wl_map *map, uint32_t side, void *data)
+wl_map_insert_new(struct wl_map *map, void *data)
{
union map_entry *start, *entry;
struct wl_array *entries;
uint32_t base;
- if (side == WL_MAP_CLIENT_SIDE) {
+ if (map->side == WL_MAP_CLIENT_SIDE) {
entries = &map->client_entries;
base = 0;
} else {
struct wl_array *entries;
if (i < WL_SERVER_ID_START) {
+ if (map->side == WL_MAP_CLIENT_SIDE)
+ return -1;
+
entries = &map->client_entries;
} else {
+ if (map->side == WL_MAP_SERVER_SIDE)
+ return -1;
+
entries = &map->server_entries;
i -= WL_SERVER_ID_START;
}
struct wl_array *entries;
if (i < WL_SERVER_ID_START) {
+ if (map->side == WL_MAP_CLIENT_SIDE)
+ return -1;
+
entries = &map->client_entries;
} else {
+ if (map->side == WL_MAP_SERVER_SIDE)
+ return -1;
+
entries = &map->server_entries;
i -= WL_SERVER_ID_START;
}
struct wl_array *entries;
if (i < WL_SERVER_ID_START) {
+ if (map->side == WL_MAP_SERVER_SIDE)
+ return;
+
entries = &map->client_entries;
} else {
+ if (map->side == WL_MAP_CLIENT_SIDE)
+ return;
+
entries = &map->server_entries;
i -= WL_SERVER_ID_START;
}