An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
922 B

  1. /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <stdbool.h>
  5. #include <stddef.h>
  6. #define hash_table_NEW(node, key, next, callback) \
  7. hash_table_new(offsetof(node, key), offsetof(node, next), \
  8. (HashFreeCallback) callback)
  9. /* Structs */
  10. typedef struct HashNode HashNode;
  11. typedef void (*HashFreeCallback)(HashNode*);
  12. typedef struct {
  13. HashNode **nodes;
  14. size_t buckets;
  15. size_t key_offset;
  16. size_t next_offset;
  17. HashFreeCallback free;
  18. } HashTable;
  19. /* Functions */
  20. HashTable* hash_table_new(size_t, size_t, HashFreeCallback);
  21. void hash_table_free(HashTable*);
  22. const HashNode* hash_table_find(const HashTable*, const char*);
  23. void hash_table_insert(HashTable*, HashNode*);
  24. bool hash_table_remove(HashTable*, const char*);