Mercurial > emacs
annotate oldXMenu/XMakeAssoc.c @ 111884:9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
gnus-sum.el (gnus-summary-enter-digest-group): Mention gnus-auto-select-on-ephemeral-exit.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Mon, 13 Dec 2010 04:22:39 +0000 |
parents | 132f2dfd549f |
children | ef719132ddfa |
rev | line source |
---|---|
25858 | 1 /* Copyright Massachusetts Institute of Technology 1985 */ |
2 | |
76133
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
3 #include "copyright.h" |
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
4 |
25858 | 5 |
6 #include <config.h> | |
7 #include <X11/Xlib.h> | |
8 #include <X11/Xresource.h> | |
9 #include "X10.h" | |
10 #include <errno.h> | |
11 | |
12 #ifndef NULL | |
13 #define NULL 0 | |
14 #endif | |
15 | |
16 struct qelem { | |
17 struct qelem *q_forw; | |
18 struct qelem *q_back; | |
19 char q_data[1]; | |
20 }; | |
109124
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
21 void emacs_insque (struct qelem *elem, struct qelem *prev); |
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
22 |
25858 | 23 /* |
24 * XMakeAssoc - Insert data into an XAssocTable keyed on an XId. | |
25 * Data is inserted into the table only once. Redundant inserts are | |
26 * meaningless (but cause no problems). The queue in each association | |
27 * bucket is sorted (lowest XId to highest XId). | |
28 */ | |
111348
a63dbe9548aa
Make Emacs compile with clang.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77837
diff
changeset
|
29 void |
109124
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
30 XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id, register caddr_t data) |
25858 | 31 { |
32 int hash; | |
33 register XAssoc *bucket; | |
34 register XAssoc *Entry; | |
35 register XAssoc *new_entry; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
36 |
25858 | 37 /* Hash the XId to get the bucket number. */ |
38 hash = x_id & (table->size - 1); | |
39 /* Look up the bucket to get the entries in that bucket. */ | |
40 bucket = &table->buckets[hash]; | |
41 /* Get the first entry in the bucket. */ | |
42 Entry = bucket->next; | |
43 | |
44 /* If (Entry != bucket), the bucket is empty so make */ | |
45 /* the new entry the first entry in the bucket. */ | |
46 /* if (Entry == bucket), the we have to search the */ | |
47 /* bucket. */ | |
48 if (Entry != bucket) { | |
49 /* The bucket isn't empty, begin searching. */ | |
50 /* If we leave the for loop then we have either passed */ | |
51 /* where the entry should be or hit the end of the bucket. */ | |
52 /* In either case we should then insert the new entry */ | |
53 /* before the current value of "Entry". */ | |
54 for (; Entry != bucket; Entry = Entry->next) { | |
55 if (Entry->x_id == x_id) { | |
56 /* Entry has the same XId... */ | |
57 if (Entry->display == dpy) { | |
58 /* Entry has the same Display... */ | |
59 /* Therefore there is already an */ | |
60 /* entry with this XId and Display, */ | |
61 /* reset its data value and return. */ | |
62 Entry->data = data; | |
63 return; | |
64 } | |
65 /* We found an association with the right */ | |
66 /* id but the wrong display! */ | |
67 continue; | |
68 } | |
69 /* If the current entry's XId is greater than the */ | |
70 /* XId of the entry to be inserted then we have */ | |
71 /* passed the location where the new XId should */ | |
72 /* be inserted. */ | |
73 if (Entry->x_id > x_id) break; | |
74 } | |
75 } | |
76 | |
77 /* If we are here then the new entry should be inserted just */ | |
78 /* before the current value of "Entry". */ | |
79 /* Create a new XAssoc and load it with new provided data. */ | |
77837
77b2ab19bece
Ulrich Mueller <ulm at gentoo.org> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
76174
diff
changeset
|
80 new_entry = (XAssoc *) malloc(sizeof(XAssoc)); |
25858 | 81 new_entry->display = dpy; |
82 new_entry->x_id = x_id; | |
83 new_entry->data = data; | |
84 | |
85 /* Insert the new entry. */ | |
86 emacs_insque((struct qelem *)new_entry, (struct qelem *)Entry->prev); | |
87 } | |
88 | |
52401 | 89 /* arch-tag: d7e3fb8a-f3b3-4c5d-a307-75ca67ec1b49 |
90 (do not change this comment) */ |