diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-19 14:10:36 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-19 14:10:36 +0000 |
commit | 56479b7346bbe9d428746fbe53755e7c790dee78 (patch) | |
tree | 5ec1afcb8173fee2e029d802902f95b29e1f9464 /st.c | |
parent | c6c0e6f26bce5ea20243c493ae53b90314b7804b (diff) | |
download | ruby-56479b7346bbe9d428746fbe53755e7c790dee78.tar.gz |
* st.c: uses malloc instead of xmalloc to avoid GC. syck uses st_insert
in gram.c to insert node from rb_syck_bad_anchor_handler into
SyckParser's hash table. if GC occurs in st_insert, it's not under
SyckParser's mark system yet. so RString can be released wrongly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 36 |
1 files changed, 12 insertions, 24 deletions
@@ -11,18 +11,6 @@ #ifdef NOT_RUBY #include "regint.h" -#else -#ifdef RUBY_PLATFORM -#define xmalloc ruby_xmalloc -#define xcalloc ruby_xcalloc -#define xrealloc ruby_xrealloc -#define xfree ruby_xfree - -void *xmalloc(size_t); -void *xcalloc(size_t, size_t); -void *xrealloc(void *, size_t); -void xfree(void *); -#endif #endif #include "st.h" @@ -65,8 +53,8 @@ static struct st_hash_type type_strhash = { static void rehash(st_table *); -#define alloc(type) (type*)xmalloc((size_t)sizeof(type)) -#define Calloc(n,s) (char*)xcalloc((n),(s)) +#define alloc(type) (type*)malloc((size_t)sizeof(type)) +#define Calloc(n,s) (char*)calloc((n),(s)) #define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0) @@ -214,12 +202,12 @@ st_free_table(st_table *table) ptr = table->bins[i]; while (ptr != 0) { next = ptr->next; - xfree(ptr); + free(ptr); ptr = next; } } - xfree(table->bins); - xfree(table); + free(table->bins); + free(table); } #define PTR_NOT_EQUAL(table, ptr, hash_val, key) \ @@ -328,7 +316,7 @@ rehash(register st_table *table) ptr = next; } } - xfree(table->bins); + free(table->bins); table->num_bins = new_num_bins; table->bins = new_bins; } @@ -350,7 +338,7 @@ st_copy(st_table *old_table) Calloc((unsigned)num_bins, sizeof(st_table_entry*)); if (new_table->bins == 0) { - xfree(new_table); + free(new_table); return 0; } @@ -360,8 +348,8 @@ st_copy(st_table *old_table) while (ptr != 0) { entry = alloc(st_table_entry); if (entry == 0) { - xfree(new_table->bins); - xfree(new_table); + free(new_table->bins); + free(new_table); return 0; } *entry = *ptr; @@ -393,7 +381,7 @@ st_delete(register st_table *table, register st_data_t *key, st_data_t *value) table->num_entries--; if (value != 0) *value = ptr->record; *key = ptr->key; - xfree(ptr); + free(ptr); return 1; } @@ -404,7 +392,7 @@ st_delete(register st_table *table, register st_data_t *key, st_data_t *value) table->num_entries--; if (value != 0) *value = tmp->record; *key = tmp->key; - xfree(tmp); + free(tmp); return 1; } } @@ -494,7 +482,7 @@ st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg) last->next = ptr->next; } ptr = ptr->next; - xfree(tmp); + free(tmp); table->num_entries--; } } |