Avoid two crashes involving windows on dead frames.
[emacs.git] / oldXMenu / XDelAssoc.c
blobec1d09d46ec09b43c89a32e9bbba101fcff76b6a
1 /* Copyright Massachusetts Institute of Technology 1985 */
3 #include "copyright.h"
5 #include "XMenuInt.h"
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).
12 void
13 XDeleteAssoc(register Display *dpy, register XAssocTable *table, register XID x_id)
15 int hash;
16 register XAssoc *bucket;
17 register XAssoc *Entry;
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;
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;
39 /* Oops, identical XId's on different displays! */
40 continue;
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;
48 /* It is apparently not in the table. */
49 return;