diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-05-22 23:30:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-05-22 23:30:52 -0400 |
commit | 793e97bb2a610dbd4cf8cfb2795f8b680d55a116 (patch) | |
tree | ed4fca067560228db3059433c82994c302f0262d /src/common/ht.h | |
parent | 9f69b3d94c86aa470d7927fe7f6a96693e5baf0c (diff) | |
download | tor-793e97bb2a610dbd4cf8cfb2795f8b680d55a116.tar.gz tor-793e97bb2a610dbd4cf8cfb2795f8b680d55a116.zip |
Add a quick macro to calculate hashtable memory usage
Diffstat (limited to 'src/common/ht.h')
-rw-r--r-- | src/common/ht.h | 4 |
1 files changed, 4 insertions, 0 deletions
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)) |