aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-16 22:03:12 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-16 22:03:12 +0000
commitaf0429b54eef973077f00d24d40fd17687a86ac0 (patch)
tree4668df34d0323fd1ae4a869d1415e6020410529b /st.c
parentdfb0fa0ca6b6d860affae3339f7bec83bb694bb4 (diff)
downloadruby-af0429b54eef973077f00d24d40fd17687a86ac0.tar.gz
* st.c, include/ruby/st.h (st_memsize): added. This function returns
the memory usage of st_talbe. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/st.c b/st.c
index 5fa7e24f53..01f2a43dc4 100644
--- a/st.c
+++ b/st.c
@@ -256,6 +256,17 @@ st_free_table(st_table *table)
free(table);
}
+size_t
+st_memsize(st_table *table)
+{
+ if (table->entries_packed) {
+ return table->num_bins * sizeof (void *) + sizeof(st_table);
+ }
+ else {
+ return table->num_entries * sizeof(struct st_table_entry) + table->num_bins * sizeof (void *) + sizeof(st_table);
+ }
+}
+
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))