btdev_struct *btdev_cache_add(BD_ADDR *bda) { btdev_struct *entry, *mount; int i, num = -1; for (i = 0; (entry = s_list_nth_data(devcache.head, i)); i++) { if (bda_equal(bda, &entry->bda)) { s_list_remove(&devcache.head, entry); num = i; break; } } if (!entry) { /* create new */ entry = malloc(sizeof(btdev_struct)); if (!entry) { perror("btdev_cache allocation failed\n"); return NULL; } memset(entry, 0, sizeof(btdev_struct)); entry->bda = *bda; entry->state = DEVSTATE_UNKNOWN; } /* find linking position */ for (i = 0; (mount = s_list_nth_data(devcache.head, i)); i++) { if (mount->state == DEVSTATE_RANGE) continue; if (mount->state == DEVSTATE_GONE || i == num) break; } s_list_insert(&devcache.head, entry, i); return entry; }
int list_add_window (unsigned long *body) { list_item *item; LOG ("list_add"); if (body[0] == None) return 0; if (s_list_find_by_data (window_list, body[0])) { LOG ("already exists!"); return 0; } if (body[0] == gnome_win) return 0; item = s_list_insert (window_list, body[0]); item->flags = body[8]; item->workspace = body[7]; item->area_x = area_x; item->area_y = area_y; gnome_check_client_hints (item->id); gnome_set_win_hints (item); gnome_set_client_list (window_list); return 1; }