From: Nick Mathewson Date: Sat, 23 May 2009 03:30:52 +0000 (-0400) Subject: Add a quick macro to calculate hashtable memory usage X-Git-Tag: tor-0.2.2.1-alpha~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=793e97bb2a610dbd4cf8cfb2795f8b680d55a116;p=thirdparty%2Ftor.git Add a quick macro to calculate hashtable memory usage --- diff --git a/src/common/ht.h b/src/common/ht.h index ff1e5551cc..be747529ab 100644 --- a/src/common/ht.h +++ b/src/common/ht.h @@ -42,6 +42,10 @@ #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))