Research portable Memory game | Исследовать портируемую игру Память
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.

33 lines
537B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "uthash.h"
  4. typedef struct {
  5. void *key;
  6. int i;
  7. UT_hash_handle hh;
  8. } el_t;
  9. int main()
  10. {
  11. el_t *d;
  12. el_t *hash = NULL;
  13. char *someaddr = NULL;
  14. el_t *e = (el_t*)malloc(sizeof(el_t));
  15. if (!e) {
  16. return -1;
  17. }
  18. e->key = (void*)someaddr;
  19. e->i = 1;
  20. HASH_ADD_PTR(hash,key,e);
  21. HASH_FIND_PTR(hash, &someaddr, d);
  22. if (d != NULL) {
  23. printf("found\n");
  24. }
  25. /* release memory */
  26. HASH_DEL(hash,e);
  27. free(e);
  28. return 0;
  29. }