An emulator, assembler, and disassembler for the Sega Game Gear
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

35 lignes
960 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. #include <unistd.h>
  7. #define hash_table_NEW(node, key, next, callback) \
  8. hash_table_new(offsetof(node, key), offsetof(node, next), \
  9. (HashFreeCallback) callback)
  10. /* Structs */
  11. typedef struct HashNode HashNode;
  12. typedef void (*HashFreeCallback)(HashNode*);
  13. typedef struct {
  14. HashNode **nodes;
  15. size_t buckets;
  16. size_t key_offset;
  17. size_t next_offset;
  18. HashFreeCallback free;
  19. } HashTable;
  20. /* Functions */
  21. HashTable* hash_table_new(size_t, size_t, HashFreeCallback);
  22. void hash_table_free(HashTable*);
  23. const HashNode* hash_table_find(const HashTable*, const char*, ssize_t);
  24. void hash_table_insert(HashTable*, HashNode*);
  25. bool hash_table_remove(HashTable*, const char*, ssize_t);