summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-20 04:13:26 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-20 04:13:26 +0000
commit534d30887d1fab63dadc0b392cda32d6f319e3b9 (patch)
tree0659845fb9f727b8322fc13672b4a33db5aa8983 /st.c
parent3b7777959a81b8f16c991518e0daf770f882bf35 (diff)
* ext/syck/rubyext.c: fixed GC problem (backported HEAD 1.55 - 1.62)
[ruby-dev:27839] * ext/syck/syck.h (S_FREE): small hack. no need to check if pointer is NULL or not before S_FREE. * 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. [ruby-dev:28057] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/st.c b/st.c
index f83b2b7..c6f0c2f 100644
--- a/st.c
+++ b/st.c
@@ -46,22 +46,10 @@ static struct st_hash_type type_strhash = {
strhash,
};
-#ifdef RUBY_PLATFORM
-#define xmalloc ruby_xmalloc
-#define xcalloc ruby_xcalloc
-#define xrealloc ruby_xrealloc
-#define xfree ruby_xfree
-
-void *xmalloc(long);
-void *xcalloc(long, long);
-void *xrealloc(void *, long);
-void xfree(void *);
-#endif
-
static void rehash(st_table *);
-#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))
-#define Calloc(n,s) (char*)xcalloc((n),(s))
+#define alloc(type) (type*)malloc((unsigned)sizeof(type))
+#define Calloc(n,s) (char*)calloc((n),(s))
#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
@@ -216,12 +204,12 @@ st_free_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) \
@@ -340,7 +328,7 @@ rehash(table)
ptr = next;
}
}
- xfree(table->bins);
+ free(table->bins);
table->num_bins = new_num_bins;
table->bins = new_bins;
}
@@ -363,7 +351,7 @@ st_copy(old_table)
Calloc((unsigned)num_bins, sizeof(st_table_entry*));
if (new_table->bins == 0) {
- xfree(new_table);
+ free(new_table);
return 0;
}
@@ -373,8 +361,8 @@ st_copy(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;
@@ -409,7 +397,7 @@ st_delete(table, key, value)
table->num_entries--;
if (value != 0) *value = ptr->record;
*key = ptr->key;
- xfree(ptr);
+ free(ptr);
return 1;
}
@@ -420,7 +408,7 @@ st_delete(table, key, value)
table->num_entries--;
if (value != 0) *value = tmp->record;
*key = tmp->key;
- xfree(tmp);
+ free(tmp);
return 1;
}
}
@@ -520,7 +508,7 @@ st_foreach(table, func, arg)
last->next = ptr->next;
}
ptr = ptr->next;
- xfree(tmp);
+ free(tmp);
table->num_entries--;
}
}