|
|
1.1 root 1: #include "copyright.h"
2:
3: /* $Header: XLookAssoc.c,v 10.14 87/09/11 07:56:40 toddb Exp $ */
4: /* Copyright Massachusetts Institute of Technology 1985 */
5:
6: #include "Xlibint.h"
7: #include "X10.h"
8:
9: /*
10: * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId.
11: * If an appropriately matching XId can be found in the table the routine will
12: * return apointer to the data associated with it. If the XId can not be found
13: * in the table the routine will return a NULL pointer. All XId's are relative
14: * to the currently active Display.
15: */
16: caddr_t XLookUpAssoc(dpy, table, x_id)
17: register Display *dpy;
18: register XAssocTable *table; /* XAssocTable to search in. */
19: register XID x_id; /* XId to search for. */
20: {
21: int hash;
22: register XAssoc *bucket;
23: register XAssoc *Entry;
24:
25: /* Hash the XId to get the bucket number. */
26: hash = x_id & (table->size - 1);
27: /* Look up the bucket to get the entries in that bucket. */
28: bucket = &table->buckets[hash];
29: /* Get the first entry in the bucket. */
30: Entry = bucket->next;
31:
32: /* Scan through the entries in the bucket for the right XId. */
33: for (; Entry != bucket; Entry = Entry->next) {
34: if (Entry->x_id == x_id) {
35: /* We have the right XId. */
36: if (Entry->display == dpy) {
37: /* We have the right display. */
38: /* We have the right entry! */
39: return(Entry->data);
40: }
41: /* Oops, identical XId's on different displays! */
42: continue;
43: }
44: if (Entry->x_id > x_id) {
45: /* We have gone past where it should be. */
46: /* It is apparently not in the table. */
47: return(NULL);
48: }
49: }
50: /* It is apparently not in the table. */
51: return(NULL);
52: }
53:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.