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