summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-25 13:57:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-25 13:57:01 +0000
commitb134b912780e0fd84fbc107a9362e45f04391b47 (patch)
tree3aad53ec0421149c8fb9e163379bba8efb2ab42e /st.c
parent4ec25bdd63c8cb9acf70880666c1d113ae0cb51e (diff)
* various files: macro fix-up by Michal Rokos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/st.c b/st.c
index 7e5ff20..9fbb178 100644
--- a/st.c
+++ b/st.c
@@ -233,16 +233,17 @@ st_free_table(table)
#define COLLISION
#endif
-#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
-bin_pos = hash_val%(table)->num_bins;\
-ptr = (table)->bins[bin_pos];\
-if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
- COLLISION;\
- while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
+#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
+ bin_pos = hash_val%(table)->num_bins;\
+ ptr = (table)->bins[bin_pos];\
+ if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
+ COLLISION;\
+ while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
+ ptr = ptr->next;\
+ }\
ptr = ptr->next;\
}\
- ptr = ptr->next;\
-}
+} while (0)
int
st_lookup(table, key, value)
@@ -266,7 +267,7 @@ st_lookup(table, key, value)
}
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
-{\
+do {\
st_table_entry *entry;\
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
rehash(table);\
@@ -281,7 +282,7 @@ st_lookup(table, key, value)
entry->next = table->bins[bin_pos];\
table->bins[bin_pos] = entry;\
table->num_entries++;\
-}
+} while (0)
int
st_insert(table, key, value)