| 1 | /* Copyright Massachusetts Institute of Technology 1985 */ |
| 2 | |
| 3 | #include "copyright.h" |
| 4 | |
| 5 | #include "XMenuInt.h" |
| 6 | |
| 7 | /* |
| 8 | * XDeleteAssoc - Delete an association in an XAssocTable keyed on |
| 9 | * an XId. An association may be removed only once. Redundant |
| 10 | * deletes are meaningless (but cause no problems). |
| 11 | */ |
| 12 | void |
| 13 | XDeleteAssoc(register Display *dpy, register XAssocTable *table, register XID x_id) |
| 14 | { |
| 15 | int hash; |
| 16 | register XAssoc *bucket; |
| 17 | register XAssoc *Entry; |
| 18 | |
| 19 | /* Hash the XId to get the bucket number. */ |
| 20 | hash = x_id & (table->size - 1); |
| 21 | /* Look up the bucket to get the entries in that bucket. */ |
| 22 | bucket = &table->buckets[hash]; |
| 23 | /* Get the first entry in the bucket. */ |
| 24 | Entry = bucket->next; |
| 25 | |
| 26 | /* Scan through the entries in the bucket for the right XId. */ |
| 27 | for (; Entry != bucket; Entry = Entry->next) { |
| 28 | if (Entry->x_id == x_id) { |
| 29 | /* We have the right XId. */ |
| 30 | if (Entry->display == dpy) { |
| 31 | /* We have the right display. */ |
| 32 | /* We have the right entry! */ |
| 33 | /* Remove it from the queue and */ |
| 34 | /* free the entry. */ |
| 35 | emacs_remque((struct qelem *)Entry); |
| 36 | free((char *)Entry); |
| 37 | return; |
| 38 | } |
| 39 | /* Oops, identical XId's on different displays! */ |
| 40 | continue; |
| 41 | } |
| 42 | if (Entry->x_id > x_id) { |
| 43 | /* We have gone past where it should be. */ |
| 44 | /* It is apparently not in the table. */ |
| 45 | return; |
| 46 | } |
| 47 | } |
| 48 | /* It is apparently not in the table. */ |
| 49 | return; |
| 50 | } |