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