From efed292c4311c8c182a32ac2afe70c6969815b2d Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 24 Dec 2007 08:06:16 +0000 Subject: * load.c (rb_feature_p): returns loading path name too. * load.c (search_required): returns path too if feature is being loaded. [ruby-dev:32048] [TODO: refactoring] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- st.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'st.c') diff --git a/st.c b/st.c index 4d21016a68..a0e669294b 100644 --- a/st.c +++ b/st.c @@ -302,6 +302,35 @@ st_lookup(st_table *table, register st_data_t key, st_data_t *value) } } +int +st_get_key(st_table *table, register st_data_t key, st_data_t *result) +{ + unsigned int hash_val, bin_pos; + register st_table_entry *ptr; + + if (table->entries_packed) { + int i; + for (i = 0; i < table->num_entries; i++) { + if ((st_data_t)table->bins[i*2] == key) { + if (result !=0) *result = (st_data_t)table->bins[i*2]; + return 1; + } + } + return 0; + } + + hash_val = do_hash(key, table); + FIND_ENTRY(table, ptr, hash_val, bin_pos); + + if (ptr == 0) { + return 0; + } + else { + if (result != 0) *result = ptr->key; + return 1; + } +} + #define ADD_DIRECT(table, key, value, hash_val, bin_pos)\ do {\ st_table_entry *entry, *head;\ -- cgit v1.2.3