summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c29
1 files changed, 29 insertions, 0 deletions
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;\