(select-safe-coding-system): Don't
[emacs.git] / oldXMenu / XDelAssoc.c
blob1c72447f931195a60d747774b6303296f7ae2e2f
1 /* Copyright Massachusetts Institute of Technology 1985 */
3 /*
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
8 documentation, and that the name of M.I.T. not be used in advertising or
9 publicity pertaining to distribution of the software without specific,
10 written prior permission. M.I.T. makes no representations about the
11 suitability of this software for any purpose. It is provided "as is"
12 without express or implied warranty.
15 #include <X11/Xlib.h>
16 #include "X10.h"
17 void emacs_remque();
18 struct qelem {
19 struct qelem *q_forw;
20 struct qelem *q_back;
21 char q_data[1];
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).
29 XDeleteAssoc(dpy, table, x_id)
30 register Display *dpy;
31 register XAssocTable *table;
32 register XID x_id;
34 int hash;
35 register XAssoc *bucket;
36 register XAssoc *Entry;
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;
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;
58 /* Oops, identical XId's on different displays! */
59 continue;
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;
67 /* It is apparently not in the table. */
68 return;
71 /* arch-tag: 90981a7e-601c-487a-b364-cdf55d6c475b
72 (do not change this comment) */