Mercurial > emacs
annotate oldXMenu/XDelAssoc.c @ 90692:d108d1785ea7
New version
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Tue, 28 Nov 2006 21:00:22 +0000 |
parents | c5406394f567 |
children | 6588c6259dfb |
rev | line source |
---|---|
25858 | 1 /* Copyright Massachusetts Institute of Technology 1985 */ |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65000
diff
changeset
|
2 /* Copyright (C) 2002, 2003, 2004, 2005, |
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65000
diff
changeset
|
3 2006 Free Software Foundation, Inc. */ |
25858 | 4 |
5 /* | |
6 Permission to use, copy, modify, distribute, and sell this software and its | |
7 documentation for any purpose is hereby granted without fee, provided that | |
8 the above copyright notice appear in all copies and that both that | |
9 copyright notice and this permission notice appear in supporting | |
10 documentation, and that the name of M.I.T. not be used in advertising or | |
11 publicity pertaining to distribution of the software without specific, | |
12 written prior permission. M.I.T. makes no representations about the | |
13 suitability of this software for any purpose. It is provided "as is" | |
14 without express or implied warranty. | |
15 */ | |
16 | |
17 #include <X11/Xlib.h> | |
18 #include "X10.h" | |
19 void emacs_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 emacs_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 | |
52401 | 73 /* arch-tag: 90981a7e-601c-487a-b364-cdf55d6c475b |
74 (do not change this comment) */ |