XDestAssoc.c 700 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. #include "XMenuInt.h"
  4. /*
  5. * XDestroyAssocTable - Destroy (free the memory associated with)
  6. * an XAssocTable.
  7. */
  8. void
  9. XDestroyAssocTable(register XAssocTable *table)
  10. {
  11. register int i;
  12. register XAssoc *bucket;
  13. register XAssoc *Entry, *entry_next;
  14. /* Free the buckets. */
  15. for (i = 0; i < table->size; i++) {
  16. bucket = &table->buckets[i];
  17. for (
  18. Entry = bucket->next;
  19. Entry != bucket;
  20. Entry = entry_next
  21. ) {
  22. entry_next = Entry->next;
  23. free((char *)Entry);
  24. }
  25. }
  26. /* Free the bucket array. */
  27. free((char *)table->buckets);
  28. /* Free the table. */
  29. free((char *)table);
  30. }