ruby-changes:12045
From: ko1 <ko1@a...>
Date: Wed, 17 Jun 2009 07:03:30 +0900 (JST)
Subject: [ruby-changes:12045] Ruby:r23712 (trunk): * st.c, include/ruby/st.h (st_memsize): added. This function returns
ko1 2009-06-17 07:03:12 +0900 (Wed, 17 Jun 2009) New Revision: 23712 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23712 Log: * st.c, include/ruby/st.h (st_memsize): added. This function returns the memory usage of st_talbe. Modified files: trunk/ChangeLog trunk/include/ruby/st.h trunk/st.c Index: include/ruby/st.h =================================================================== --- include/ruby/st.h (revision 23711) +++ include/ruby/st.h (revision 23712) @@ -107,6 +107,7 @@ int st_numhash(st_data_t); int st_strcasecmp(const char *s1, const char *s2); int st_strncasecmp(const char *s1, const char *s2, size_t n); +size_t st_memsize(st_table *); #if defined(__cplusplus) #if 0 Index: ChangeLog =================================================================== --- ChangeLog (revision 23711) +++ ChangeLog (revision 23712) @@ -1,3 +1,8 @@ +Wed Jun 17 06:48:28 2009 Koichi Sasada <ko1@a...> + + * st.c, include/ruby/st.h (st_memsize): added. This function returns + the memory usage of st_talbe. + Wed Jun 17 06:19:06 2009 Koichi Sasada <ko1@a...> * include/ruby/ruby.h: New structure RTypedData, added. Index: st.c =================================================================== --- st.c (revision 23711) +++ st.c (revision 23712) @@ -256,6 +256,17 @@ 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))) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/