1 /* Copyright Massachusetts Institute of Technology 1985 */
7 #include <X11/Xresource.h>
15 * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId.
16 * If an appropriately matching XId can be found in the table the routine will
17 * return apointer to the data associated with it. If the XId can not be found
18 * in the table the routine will return a NULL pointer. All XId's are relative
19 * to the currently active Display.
21 caddr_t
XLookUpAssoc(Display
*dpy
,
22 XAssocTable
*table
, /* XAssocTable to search in. */
23 XID x_id
) /* XId to search for. */
26 register XAssoc
*bucket
;
27 register XAssoc
*Entry
;
29 /* Hash the XId to get the bucket number. */
30 hash
= x_id
& (table
->size
- 1);
31 /* Look up the bucket to get the entries in that bucket. */
32 bucket
= &table
->buckets
[hash
];
33 /* Get the first entry in the bucket. */
36 /* Scan through the entries in the bucket for the right XId. */
37 for (; Entry
!= bucket
; Entry
= Entry
->next
) {
38 if (Entry
->x_id
== x_id
) {
39 /* We have the right XId. */
40 if (Entry
->display
== dpy
) {
41 /* We have the right display. */
42 /* We have the right entry! */
45 /* Oops, identical XId's on different displays! */
48 if (Entry
->x_id
> x_id
) {
49 /* We have gone past where it should be. */
50 /* It is apparently not in the table. */
54 /* It is apparently not in the table. */