* 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
This commit is contained in:
ocean 2005-12-19 14:10:36 +00:00
parent c6c0e6f26b
commit 56479b7346
2 changed files with 19 additions and 24 deletions

View File

@ -1,3 +1,10 @@
Mon Dec 19 23:09:24 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* 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.
Mon Dec 19 12:20:59 2005 Tanaka Akira <akr@m17n.org>
* eval.c (FUNCTION_CALL_MAY_RETURN_TWICE): activate only

36
st.c
View File

@ -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--;
}
}