From 93a405bdba075600b36f3ceef2b2ff94a119369c Mon Sep 17 00:00:00 2001 From: ocean Date: Mon, 19 Dec 2005 14:10:36 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@9712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- st.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 220610094..6bcd05879 100644 --- a/st.c +++ b/st.c @@ -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--; } } -- cgit