1 /* Copyright Massachusetts Institute of Technology 1985 */ 2 3 /* 4 5 Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology 6 7 Permission to use, copy, modify, and distribute this 8 software and its documentation for any purpose and without 9 fee is hereby granted, provided that the above copyright 10 notice appear in all copies and that both that copyright 11 notice and this permission notice appear in supporting 12 documentation, and that the name of M.I.T. not be used in 13 advertising or publicity pertaining to distribution of the 14 software without specific, written prior permission. 15 M.I.T. makes no representations about the suitability of 16 this software for any purpose. It is provided "as is" 17 without express or implied warranty. 18 19 */ 20 21 22 23 #include "XMenuInt.h" 24 25 /* 26 * XDeleteAssoc - Delete an association in an XAssocTable keyed on 27 * an XId. An association may be removed only once. Redundant 28 * deletes are meaningless (but cause no problems). 29 */ 30 void 31 XDeleteAssoc(register Display *dpy, register XAssocTable *table, register XID x_id) 32 { 33 int hash; 34 register XAssoc *bucket; 35 register XAssoc *Entry; 36 37 /* Hash the XId to get the bucket number. */ 38 hash = x_id & (table->size - 1); 39 /* Look up the bucket to get the entries in that bucket. */ 40 bucket = &table->buckets[hash]; 41 /* Get the first entry in the bucket. */ 42 Entry = bucket->next; 43 44 /* Scan through the entries in the bucket for the right XId. */ 45 for (; Entry != bucket; Entry = Entry->next) { 46 if (Entry->x_id == x_id) { 47 /* We have the right XId. */ 48 if (Entry->display == dpy) { 49 /* We have the right display. */ 50 /* We have the right entry! */ 51 /* Remove it from the queue and */ 52 /* free the entry. */ 53 emacs_remque((struct qelem *)Entry); 54 free((char *)Entry); 55 return; 56 } 57 /* Oops, identical XId's on different displays! */ 58 continue; 59 } 60 if (Entry->x_id > x_id) { 61 /* We have gone past where it should be. */ 62 /* It is apparently not in the table. */ 63 return; 64 } 65 } 66 /* It is apparently not in the table. */ 67 return; 68 }