]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a quick macro to calculate hashtable memory usage
authorNick Mathewson <nickm@torproject.org>
Sat, 23 May 2009 03:30:52 +0000 (23:30 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 23 May 2009 03:30:52 +0000 (23:30 -0400)
src/common/ht.h

index ff1e5551cc440fcce0e963eabf7f9ca59d868dc3..be747529ab88cbbc8f7e9d3859ea7c28c8402a58 100644 (file)
 #define HT_SIZE(head)                           \
   ((head)->hth_n_entries)
 
+/* Return memory usage for a hashtable (not counting the entries themselves) */
+#define HT_MEM_USAGE(head)                         \
+  (sizeof(*head) + (head)->hth_table_length * sizeof(void*))
+
 #define HT_FIND(name, head, elm)     name##_HT_FIND((head), (elm))
 #define HT_INSERT(name, head, elm)   name##_HT_INSERT((head), (elm))
 #define HT_REPLACE(name, head, elm)  name##_HT_REPLACE((head), (elm))