diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-07-15 07:59:59 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-07-15 07:59:59 +0000 |
commit | 86307f52ee1b3c5aa76e2fd6ee118e681dd76905 (patch) | |
tree | 4f5675ce901200d4245c6697d4e8d1c224949174 /st.c | |
parent | e12510c502a3c8a81aeda66d1867eb1e760ce533 (diff) |
990715
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -403,16 +403,8 @@ st_delete_safe(table, key, value, never) return 0; } - if (EQUAL(table, *key, ptr->key)) { - table->num_entries--; - *key = ptr->key; - if (value != 0) *value = ptr->record; - ptr->key = ptr->record = never; - return 1; - } - - for(; ptr->next != 0; ptr = ptr->next) { - if (EQUAL(table, ptr->next->key, *key)) { + for(; ptr != 0; ptr = ptr->next) { + if (EQUAL(table, ptr->key, *key)) { table->num_entries--; *key = ptr->key; if (value != 0) *value = ptr->record; @@ -424,6 +416,25 @@ st_delete_safe(table, key, value, never) return 0; } +static int +delete_never(key, value, never) + char *key, *value, *never; +{ + if (value == never) return ST_DELETE; + return ST_CONTINUE; +} + +void +st_cleanup_safe(table, never) + st_table *table; + char *never; +{ + int num_entries = table->num_entries; + + st_foreach(table, delete_never, never); + table->num_entries = num_entries; +} + void st_foreach(table, func, arg) st_table *table; |