XDelAssoc.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. #include "XMenuInt.h"
  4. /*
  5. * XDeleteAssoc - Delete an association in an XAssocTable keyed on
  6. * an XId. An association may be removed only once. Redundant
  7. * deletes are meaningless (but cause no problems).
  8. */
  9. void
  10. XDeleteAssoc(register Display *dpy, register XAssocTable *table, register XID x_id)
  11. {
  12. int hash;
  13. register XAssoc *bucket;
  14. register XAssoc *Entry;
  15. /* Hash the XId to get the bucket number. */
  16. hash = x_id & (table->size - 1);
  17. /* Look up the bucket to get the entries in that bucket. */
  18. bucket = &table->buckets[hash];
  19. /* Get the first entry in the bucket. */
  20. Entry = bucket->next;
  21. /* Scan through the entries in the bucket for the right XId. */
  22. for (; Entry != bucket; Entry = Entry->next) {
  23. if (Entry->x_id == x_id) {
  24. /* We have the right XId. */
  25. if (Entry->display == dpy) {
  26. /* We have the right display. */
  27. /* We have the right entry! */
  28. /* Remove it from the queue and */
  29. /* free the entry. */
  30. emacs_remque((struct qelem *)Entry);
  31. free((char *)Entry);
  32. return;
  33. }
  34. /* Oops, identical XId's on different displays! */
  35. continue;
  36. }
  37. if (Entry->x_id > x_id) {
  38. /* We have gone past where it should be. */
  39. /* It is apparently not in the table. */
  40. return;
  41. }
  42. }
  43. /* It is apparently not in the table. */
  44. return;
  45. }