11 typedef struct Intlist Intlist;
38 allocmap(void (*inc)(void*))
42 m = emalloc9p(sizeof(*m));
50 freemap(Intmap *map, void (*destroy)(void*))
57 for(i=0; i<NHASH; i++){
58 for(p=map->hash[i]; p; p=nlink){
69 llookup(Intmap *map, ulong id)
73 for(lf=&map->hash[hashid(id)]; *lf; lf=&(*lf)->link)
80 * The RWlock is used as expected except that we allow
81 * inc() to be called while holding it. This is because we're
82 * locking changes to the tree structure, not to the references.
83 * Inc() is expected to have its own locking.
86 lookupkey(Intmap *map, ulong id)
92 if(f = *llookup(map, id)){
102 insertkey(Intmap *map, ulong id, void *v)
109 if(f = *llookup(map, id)){
110 /* no decrement for ov because we're returning it */
114 f = emalloc9p(sizeof(*f));
118 f->link = map->hash[h];
127 caninsertkey(Intmap *map, ulong id, void *v)
134 if(*llookup(map, id))
137 f = emalloc9p(sizeof *f);
141 f->link = map->hash[h];
150 deletekey(Intmap *map, ulong id)
156 if(f = *(lf = llookup(map, id))){