]> code.delx.au - gnu-emacs/blob - oldXMenu/XDelAssoc.c
Remove license text in favour of including copyright.h, as was done in
[gnu-emacs] / oldXMenu / XDelAssoc.c
1 /* Copyright Massachusetts Institute of Technology 1985 */
2 /* Copyright (C) 2001, 2002, 2003, 2004, 2005,
3 2006, 2007 Free Software Foundation, Inc. */
4
5 #include "copyright.h"
6
7
8 #include <X11/Xlib.h>
9 #include "X10.h"
10 void emacs_remque();
11 struct qelem {
12 struct qelem *q_forw;
13 struct qelem *q_back;
14 char q_data[1];
15 };
16
17 /*
18 * XDeleteAssoc - Delete an association in an XAssocTable keyed on
19 * an XId. An association may be removed only once. Redundant
20 * deletes are meaningless (but cause no problems).
21 */
22 XDeleteAssoc(dpy, table, x_id)
23 register Display *dpy;
24 register XAssocTable *table;
25 register XID x_id;
26 {
27 int hash;
28 register XAssoc *bucket;
29 register XAssoc *Entry;
30
31 /* Hash the XId to get the bucket number. */
32 hash = x_id & (table->size - 1);
33 /* Look up the bucket to get the entries in that bucket. */
34 bucket = &table->buckets[hash];
35 /* Get the first entry in the bucket. */
36 Entry = bucket->next;
37
38 /* Scan through the entries in the bucket for the right XId. */
39 for (; Entry != bucket; Entry = Entry->next) {
40 if (Entry->x_id == x_id) {
41 /* We have the right XId. */
42 if (Entry->display == dpy) {
43 /* We have the right display. */
44 /* We have the right entry! */
45 /* Remove it from the queue and */
46 /* free the entry. */
47 emacs_remque((struct qelem *)Entry);
48 free((char *)Entry);
49 return;
50 }
51 /* Oops, identical XId's on different displays! */
52 continue;
53 }
54 if (Entry->x_id > x_id) {
55 /* We have gone past where it should be. */
56 /* It is apparently not in the table. */
57 return;
58 }
59 }
60 /* It is apparently not in the table. */
61 return;
62 }
63
64 /* arch-tag: 90981a7e-601c-487a-b364-cdf55d6c475b
65 (do not change this comment) */