- create a table:
Table *display_table;
- give it a release function pointer if needed:
void release_display(void *display) { Display *dis = (Display *)display; CFRelease(dis->uuid); } display_table->release = &release_display;
-
insert the table to a bucket, passing the table, the struct value to be used as table key, and the struct to store
table_insert(display_table, display->did, (void *)display);
-
table_free(display_table);
to clear it -
To get items, create a get function for whatever struct you add, taking the field you set to be the table key
Display *get_display(int did) { Display *display; display = (Display *)table_search(display_table, did); return display; }```
-
to delete items, create a delete function for your struct that calls
table_delete_item(Table *table, int key)
with the table and keyvoid remove_process(ProcessSerialNumber psn) { table_delete_item(proc_table, psn.lowLongOfPSN); }
See source/display.c from mac-window for more indepth usage examples