summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-31 09:13:34 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-31 09:13:34 +0000
commit8a4cbc733114d0a51bc324b466764d10985cbd80 (patch)
tree218dc2e4d069b9656143ab3e0de06aaa97c26209 /st.c
parent1307f8d555235116f0f0c79b9902df9cfd4bff12 (diff)
990531
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/st.c b/st.c
index 9a3353a76e..25ed0873f3 100644
--- a/st.c
+++ b/st.c
@@ -45,9 +45,11 @@ static struct st_hash_type type_strhash = {
strhash,
};
+#ifndef xmalloc
void *xmalloc();
void *xcalloc();
void *xrealloc();
+#endif
static void rehash();
#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))
@@ -220,19 +222,19 @@ st_lookup(table, key, value)
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
{\
- st_table_entry *tbl;\
+ st_table_entry *entry;\
if (table->num_entries/table->num_bins > ST_DEFAULT_MAX_DENSITY) {\
rehash(table);\
bin_pos = hash_val % table->num_bins;\
}\
\
- tbl = alloc(st_table_entry);\
+ entry = alloc(st_table_entry);\
\
- tbl->hash = hash_val;\
- tbl->key = key;\
- tbl->record = value;\
- tbl->next = table->bins[bin_pos];\
- table->bins[bin_pos] = tbl;\
+ entry->hash = hash_val;\
+ entry->key = key;\
+ entry->record = value;\
+ entry->next = table->bins[bin_pos];\
+ table->bins[bin_pos] = entry;\
table->num_entries++;\
}
@@ -301,7 +303,7 @@ st_copy(old_table)
st_table *old_table;
{
st_table *new_table;
- st_table_entry *ptr, *tbl;
+ st_table_entry *ptr, *entry;
int i, num_bins = old_table->num_bins;
new_table = alloc(st_table);
@@ -322,15 +324,15 @@ st_copy(old_table)
new_table->bins[i] = 0;
ptr = old_table->bins[i];
while (ptr != 0) {
- tbl = alloc(st_table_entry);
- if (tbl == 0) {
+ entry = alloc(st_table_entry);
+ if (entry == 0) {
free(new_table->bins);
free(new_table);
return 0;
}
- *tbl = *ptr;
- tbl->next = new_table->bins[i];
- new_table->bins[i] = tbl;
+ *entry = *ptr;
+ entry->next = new_table->bins[i];
+ new_table->bins[i] = entry;
ptr = ptr->next;
}
}