Annotation of 43BSD/contrib/X/Xlib/XDeleteAssoc.c, revision 1.1.1.1

1.1       root        1: #include <X/mit-copyright.h>
                      2: 
                      3: /* $Header: XDeleteAssoc.c,v 10.4 86/02/01 15:31:59 tony Rel $ */
                      4: /* Copyright    Massachusetts Institute of Technology    1985  */
                      5: 
                      6: #include "XlibInternal.h"
                      7: 
                      8: /*
                      9:  * XDeleteAssoc - Delete an association in an XAssocTable keyed on
                     10:  * an XId.  An association may be removed only once.  Redundant
                     11:  * deletes are meaningless (but cause no problems).
                     12:  */
                     13: XDeleteAssoc(table, x_id)
                     14:        register XAssocTable *table;
                     15:        register XId x_id;
                     16: {
                     17:        int hash;
                     18:        register XAssoc *bucket;
                     19:        register XAssoc *entry;
                     20: 
                     21:        /* Hash the XId to get the bucket number. */
                     22:        hash = x_id & (table->size - 1);
                     23:        /* Look up the bucket to get the entries in that bucket. */
                     24:        bucket = &(*table->table)[hash];
                     25:        /* Get the first entry in the bucket. */
                     26:        entry = bucket->next;
                     27: 
                     28:        /* Scan through the entries in the bucket for the right XId. */
                     29:        for (entry; entry != bucket; entry = entry->next) {
                     30:                if (entry->x_id == x_id) {
                     31:                        /* We have the right XId. */
                     32:                        if (entry->display == _XlibCurrentDisplay) {
                     33:                                /* We have the right display. */
                     34:                                /* We have the right entry! */
                     35:                                /* Remove it from the queue and */
                     36:                                /* free the entry. */
                     37:                                remque(entry);
                     38:                                free(entry);
                     39:                                return;
                     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;
                     48:                }
                     49:        }
                     50:        /* It is apparently not in the table. */
                     51:        return;
                     52: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.