record_table.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * This file is part of the zlog Library.
  3. *
  4. * Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING in base directory.
  7. */
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include <errno.h>
  11. #include "zc_defs.h"
  12. #include "record_table.h"
  13. void zlog_record_table_profile(zc_hashtable_t * records, int flag)
  14. {
  15. zc_hashtable_entry_t *a_entry;
  16. zlog_record_t *a_record;
  17. zc_assert(records,);
  18. zc_profile(flag, "-record_table[%p]-", records);
  19. zc_hashtable_foreach(records, a_entry) {
  20. a_record = (zlog_record_t *) a_entry->value;
  21. zlog_record_profile(a_record, flag);
  22. }
  23. return;
  24. }
  25. /*******************************************************************************/
  26. void zlog_record_table_del(zc_hashtable_t * records)
  27. {
  28. zc_assert(records,);
  29. zc_hashtable_del(records);
  30. zc_debug("zlog_record_table_del[%p]", records);
  31. return;
  32. }
  33. zc_hashtable_t *zlog_record_table_new(void)
  34. {
  35. zc_hashtable_t *records;
  36. records = zc_hashtable_new(20,
  37. (zc_hashtable_hash_fn) zc_hashtable_str_hash,
  38. (zc_hashtable_equal_fn) zc_hashtable_str_equal,
  39. NULL, (zc_hashtable_del_fn) zlog_record_del);
  40. if (!records) {
  41. zc_error("zc_hashtable_new fail");
  42. return NULL;
  43. } else {
  44. zlog_record_table_profile(records, ZC_DEBUG);
  45. return records;
  46. }
  47. }
  48. /*******************************************************************************/