summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-08 10:01:40 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-08 10:01:40 +0000
commit72ba13aa8e86eb7f12bd17737a689ad2ec214036 (patch)
treea45e9d137742a163baea3ee66c918c18b9808b1e
parent4a7311e12977ca2cd388f609c3c705ba219bfee5 (diff)
* array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c, io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c, string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c, vm.c, gc.c: allocated memory objects by xmalloc (ruby_xmalloc) should be freed by xfree (ruby_xfree). * ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c, ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c, ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c, ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c, ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog17
-rw-r--r--array.c2
-rw-r--r--bignum.c2
-rw-r--r--cont.c3
-rw-r--r--dir.c41
-rw-r--r--dln.c2
-rw-r--r--encoding.c2
-rw-r--r--enumerator.c3
-rw-r--r--eval_jump.c4
-rw-r--r--ext/curses/curses.c2
-rw-r--r--ext/dbm/dbm.c2
-rw-r--r--ext/digest/digest.c2
-rw-r--r--ext/gdbm/gdbm.c2
-rw-r--r--ext/json/ext/parser/parser.c2
-rw-r--r--ext/json/ext/parser/unicode.c8
-rw-r--r--ext/openssl/ossl_cipher.c2
-rw-r--r--ext/openssl/ossl_hmac.c2
-rw-r--r--ext/openssl/ossl_pkey_ec.c4
-rw-r--r--ext/sdbm/init.c2
-rw-r--r--ext/strscan/strscan.c2
-rw-r--r--ext/zlib/zlib.c6
-rw-r--r--file.c18
-rw-r--r--gc.c40
-rw-r--r--hash.c2
-rw-r--r--io.c2
-rw-r--r--load.c2
-rw-r--r--pack.c4
-rw-r--r--proc.c11
-rw-r--r--random.c2
-rw-r--r--re.c2
-rw-r--r--ruby.c4
-rw-r--r--st.c1
-rw-r--r--string.c8
-rw-r--r--thread.c7
-rw-r--r--thread_pthread.c4
-rw-r--r--time.c8
-rw-r--r--util.c4
-rw-r--r--variable.c6
-rw-r--r--version.h6
-rw-r--r--vm.c8
40 files changed, 133 insertions, 118 deletions
diff --git a/ChangeLog b/ChangeLog
index e33c84e..8f3cda8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Sun Jun 8 18:15:38 2008 Koichi Sasada <ko1@atdot.net>
+
+ * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
+ enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
+ io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
+ string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
+ vm.c, gc.c:
+ allocated memory objects by xmalloc (ruby_xmalloc) should be
+ freed by xfree (ruby_xfree).
+
+ * ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
+ ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
+ ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
+ ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
+ ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
+ ditto.
+
Sun Jun 8 01:15:11 2008 Tanaka Akira <akr@fsij.org>
* hash.c (hash_i): make Hash#hash order insensitive.
diff --git a/array.c b/array.c
index 8622b61..fdf1808 100644
--- a/array.c
+++ b/array.c
@@ -292,7 +292,7 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
rb_ary_modify(ary);
if (argc == 0) {
if (RARRAY_PTR(ary) && !ARY_SHARED_P(ary)) {
- free(RARRAY(ary)->ptr);
+ xfree(RARRAY(ary)->ptr);
}
RARRAY(ary)->len = 0;
if (rb_block_given_p()) {
diff --git a/bignum.c b/bignum.c
index 277923f..e9b7726 100644
--- a/bignum.c
+++ b/bignum.c
@@ -93,7 +93,7 @@ rb_big_realloc(VALUE big, long len)
RBIGNUM_SET_LEN(big, len);
if (ds) {
MEMCPY(RBIGNUM(big)->as.ary, ds, BDIGIT, len);
- free(ds);
+ xfree(ds);
}
}
else {
diff --git a/cont.c b/cont.c
index 57b95fe..10f418d 100644
--- a/cont.c
+++ b/cont.c
@@ -158,8 +158,7 @@ cont_new(VALUE klass)
volatile VALUE contval;
rb_thread_t *th = GET_THREAD();
- contval = Data_Make_Struct(klass, rb_context_t,
- cont_mark, cont_free, cont);
+ contval = Data_Make_Struct(klass, rb_context_t, cont_mark, cont_free, cont);
cont->self = contval;
cont->alive = Qtrue;
diff --git a/dir.c b/dir.c
index 7958d68..55783b1 100644
--- a/dir.c
+++ b/dir.c
@@ -349,9 +349,9 @@ free_dir(struct dir_data *dir)
{
if (dir) {
if (dir->dir) closedir(dir->dir);
- if (dir->path) free(dir->path);
+ if (dir->path) xfree(dir->path);
}
- free(dir);
+ xfree(dir);
}
static VALUE dir_close(VALUE);
@@ -382,7 +382,7 @@ dir_initialize(VALUE dir, VALUE dirname)
FilePathValue(dirname);
Data_Get_Struct(dir, struct dir_data, dp);
if (dp->dir) closedir(dp->dir);
- if (dp->path) free(dp->path);
+ if (dp->path) xfree(dp->path);
dp->dir = NULL;
dp->path = NULL;
dp->dir = opendir(RSTRING_PTR(dirname));
@@ -780,7 +780,7 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
struct chdir_data args;
char *cwd = my_getcwd();
- args.old_path = rb_tainted_str_new2(cwd); free(cwd);
+ args.old_path = rb_tainted_str_new2(cwd); xfree(cwd);
args.new_path = path;
args.done = Qfalse;
return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
@@ -811,7 +811,7 @@ dir_s_getwd(VALUE dir)
path = my_getcwd();
cwd = rb_tainted_str_new2(path);
- free(path);
+ xfree(path);
return cwd;
}
@@ -917,6 +917,7 @@ sys_warning_1(const char* mesg)
#define GLOB_ALLOC(type) (type *)malloc(sizeof(type))
#define GLOB_ALLOC_N(type, n) (type *)malloc(sizeof(type) * (n))
+#define GLOB_FREE(ptr) free(ptr)
#define GLOB_JUMP_TAG(status) ((status == -1) ? rb_memerror() : rb_jump_tag(status))
/*
@@ -1081,7 +1082,7 @@ glob_make_pattern(const char *p, int flags)
const char *m = find_dirsep(p, flags);
char *buf = GLOB_ALLOC_N(char, m-p+1);
if (!buf) {
- free(tmp);
+ GLOB_FREE(tmp);
goto error;
}
memcpy(buf, p, m-p);
@@ -1123,8 +1124,8 @@ glob_free_pattern(struct glob_pattern *list)
struct glob_pattern *tmp = list;
list = list->next;
if (tmp->str)
- free(tmp->str);
- free(tmp);
+ GLOB_FREE(tmp->str);
+ GLOB_FREE(tmp);
}
}
@@ -1246,7 +1247,7 @@ glob_helper(
char *tmp = join_path(path, dirsep, "");
if (!tmp) return -1;
status = glob_call_func(func, tmp, arg);
- free(tmp);
+ GLOB_FREE(tmp);
if (status) return status;
}
}
@@ -1298,8 +1299,8 @@ glob_helper(
}
status = glob_helper(buf, 1, YES, new_isdir, new_beg, new_end, flags, func, arg);
- free(buf);
- free(new_beg);
+ GLOB_FREE(buf);
+ GLOB_FREE(new_beg);
if (status) break;
}
@@ -1327,7 +1328,7 @@ glob_helper(
new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
if (!new_beg) {
- free(name);
+ GLOB_FREE(name);
status = -1;
break;
}
@@ -1340,20 +1341,20 @@ glob_helper(
}
buf = join_path(path, dirsep, name);
- free(name);
+ GLOB_FREE(name);
if (!buf) {
- free(new_beg);
+ GLOB_FREE(new_beg);
status = -1;
break;
}
status = glob_helper(buf, 1, UNKNOWN, UNKNOWN, new_beg, new_end, flags, func, arg);
- free(buf);
- free(new_beg);
+ GLOB_FREE(buf);
+ GLOB_FREE(new_beg);
if (status) break;
}
}
- free(copy_beg);
+ GLOB_FREE(copy_beg);
}
return status;
@@ -1384,12 +1385,12 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg)
list = glob_make_pattern(root, flags);
if (!list) {
- free(buf);
+ GLOB_FREE(buf);
return -1;
}
status = glob_helper(buf, 0, UNKNOWN, UNKNOWN, &list, &list + 1, flags, func, arg);
glob_free_pattern(list);
- free(buf);
+ GLOB_FREE(buf);
return status;
}
@@ -1486,7 +1487,7 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg)
status = ruby_brace_expand(buf, flags, func, arg);
if (status) break;
}
- free(buf);
+ GLOB_FREE(buf);
}
else if (!lbrace && !rbrace) {
status = (*func)(s, arg);
diff --git a/dln.c b/dln.c
index 13f6e29..219a22d 100644
--- a/dln.c
+++ b/dln.c
@@ -42,6 +42,8 @@ void *xcalloc();
void *xrealloc();
#endif
+#define free(x) xfree(x)
+
#include <stdio.h>
#if defined(_WIN32) || defined(__VMS)
#include "missing/file.h"
diff --git a/encoding.c b/encoding.c
index ffeb62b..b1fc140 100644
--- a/encoding.c
+++ b/encoding.c
@@ -154,7 +154,7 @@ enc_register_at(int index, const char *name, rb_encoding *encoding)
return -1;
}
if (!ent->enc) {
- ent->enc = malloc(sizeof(rb_encoding));
+ ent->enc = xmalloc(sizeof(rb_encoding));
}
else {
obj = ent->enc->auxiliary_data;
diff --git a/enumerator.c b/enumerator.c
index afde97e..3f52626 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -206,8 +206,7 @@ enumerator_allocate(VALUE klass)
struct enumerator *ptr;
VALUE enum_obj;
- enum_obj = Data_Make_Struct(klass, struct enumerator,
- enumerator_mark, -1, ptr);
+ enum_obj = Data_Make_Struct(klass, struct enumerator, enumerator_mark, -1, ptr);
ptr->obj = Qundef;
return enum_obj;
diff --git a/eval_jump.c b/eval_jump.c
index 1d6a84d..f474844 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -120,7 +120,7 @@ rb_exec_end_proc(void)
}
tmp = link;
tmp_end_procs = link = link->next;
- free(tmp);
+ xfree(tmp);
}
}
while (end_procs) {
@@ -138,7 +138,7 @@ rb_exec_end_proc(void)
}
tmp = link;
tmp_end_procs = link = link->next;
- free(tmp);
+ xfree(tmp);
}
}
rb_set_safe_level_force(safe);
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 615bd65..7d4ed87 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -635,7 +635,7 @@ static void
curses_mousedata_free(struct mousedata *mdata)
{
if (mdata->mevent)
- free(mdata->mevent);
+ xfree(mdata->mevent);
}
static VALUE
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 8cad97c..42bd4ff 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -52,7 +52,7 @@ free_dbm(struct dbmdata *dbmp)
{
if (dbmp) {
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
- free(dbmp);
+ xfree(dbmp);
}
}
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 4156575..65ec89a 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -469,7 +469,7 @@ rb_digest_base_alloc(VALUE klass)
pctx = xmalloc(algo->ctx_size);
algo->init_func(pctx);
- obj = Data_Wrap_Struct(klass, 0, free, pctx);
+ obj = Data_Wrap_Struct(klass, 0, xfree, pctx);
return obj;
}
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 04fdf88..e6a6e0d 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -110,7 +110,7 @@ free_dbm(struct dbmdata *dbmp)
{
if (dbmp) {
if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
- free(dbmp);
+ xfree(dbmp);
}
}
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index 5a5d6f1..25a8ae1 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -1705,7 +1705,7 @@ static void JSON_mark(JSON_Parser *json)
static void JSON_free(JSON_Parser *json)
{
- free(json);
+ ruby_xfree(json);
}
static VALUE cJSON_parser_s_allocate(VALUE klass)
diff --git a/ext/json/ext/parser/unicode.c b/ext/json/ext/parser/unicode.c
index 609a0e8..f196727 100644
--- a/ext/json/ext/parser/unicode.c
+++ b/ext/json/ext/parser/unicode.c
@@ -105,12 +105,12 @@ char *JSON_convert_UTF16_to_UTF8 (
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
++tmpPtr;
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- free(tmp);
+ ruby_xfree(tmp);
rb_raise(rb_path2class("JSON::ParserError"),
"source sequence is illegal/malformed near %s", source);
}
} else { /* We don't have the 16 bits following the high surrogate. */
- free(tmp);
+ ruby_xfree(tmp);
rb_raise(rb_path2class("JSON::ParserError"),
"partial character in source, but hit end near %s", source);
break;
@@ -118,7 +118,7 @@ char *JSON_convert_UTF16_to_UTF8 (
} else if (flags == strictConversion) {
/* UTF-16 surrogate values are illegal in UTF-32 */
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- free(tmp);
+ ruby_xfree(tmp);
rb_raise(rb_path2class("JSON::ParserError"),
"source sequence is illegal/malformed near %s", source);
}
@@ -150,7 +150,7 @@ char *JSON_convert_UTF16_to_UTF8 (
}
rb_str_buf_cat(buffer, p, bytesToWrite);
}
- free(tmp);
+ ruby_xfree(tmp);
source += 5 + (n - 1) * 6;
return source;
}
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index b680dc6..4cae509 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -67,7 +67,7 @@ ossl_cipher_free(EVP_CIPHER_CTX *ctx)
{
if (ctx) {
EVP_CIPHER_CTX_cleanup(ctx);
- free(ctx);
+ ruby_xfree(ctx);
}
}
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index ef77d6c..f8098bb 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -42,7 +42,7 @@ static void
ossl_hmac_free(HMAC_CTX *ctx)
{
HMAC_CTX_cleanup(ctx);
- free(ctx);
+ ruby_xfree(ctx);
}
static VALUE
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
index 2100541..390c5ac 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -695,7 +695,7 @@ static void ossl_ec_group_free(ossl_ec_group *ec_group)
{
if (!ec_group->dont_free && ec_group->group)
EC_GROUP_clear_free(ec_group->group);
- free(ec_group);
+ ruby_xfree(ec_group);
}
static VALUE ossl_ec_group_alloc(VALUE klass)
@@ -1201,7 +1201,7 @@ static void ossl_ec_point_free(ossl_ec_point *ec_point)
{
if (!ec_point->dont_free && ec_point->point)
EC_POINT_clear_free(ec_point->point);
- free(ec_point);
+ ruby_xfree(ec_point);
}
static VALUE ossl_ec_point_alloc(VALUE klass)
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 239e7f2..70480f4 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -44,7 +44,7 @@ free_sdbm(struct dbmdata *dbmp)
{
if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
- free(dbmp);
+ ruby_xfree(dbmp);
}
static VALUE
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 7c6cf05..622bfae 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -166,7 +166,7 @@ static void
strscan_free(struct strscanner *p)
{
onig_region_free(&(p->regs), 0);
- free(p);
+ ruby_xfree(p);
}
static VALUE
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index b06ebe3..66616fb 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -398,7 +398,7 @@ zlib_mem_alloc(voidpf opaque, uInt items, uInt size)
static void
zlib_mem_free(voidpf opaque, voidpf address)
{
- free(address);
+ xfree(address);
}
static void
@@ -793,7 +793,7 @@ zstream_free(struct zstream *z)
if (ZSTREAM_IS_READY(z)) {
zstream_finalize(z);
}
- free(z);
+ xfree(z);
}
static VALUE
@@ -1676,7 +1676,7 @@ gzfile_free(struct gzfile *gz)
}
zstream_finalize(z);
}
- free(gz);
+ xfree(gz);
}
static VALUE
diff --git a/file.c b/file.c
index 447be55..1d1fab2 100644
--- a/file.c
+++ b/file.c
@@ -184,7 +184,7 @@ stat_new_0(VALUE klass, struct stat *st)
nst = ALLOC(struct stat);
*nst = *st;
}
- return Data_Wrap_Struct(klass, NULL, free, nst);
+ return Data_Wrap_Struct(klass, NULL, -1, nst);
}
static VALUE
@@ -2276,11 +2276,11 @@ rb_file_s_readlink(VALUE klass, VALUE path)
buf = xrealloc(buf, size);
}
if (rv < 0) {
- free(buf);
+ xfree(buf);
rb_sys_fail(RSTRING_PTR(path));
}
v = rb_tainted_str_new(buf, rv);
- free(buf);
+ xfree(buf);
return v;
#else
@@ -2453,7 +2453,7 @@ getcwdofdrv(int drv)
if (chdir(drive) == 0) {
drvcwd = my_getcwd();
chdir(oldcwd);
- free(oldcwd);
+ xfree(oldcwd);
}
else {
/* perhaps the drive is not exist. we return only drive letter */
@@ -2688,7 +2688,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
dirlen = strlen(dir);
BUFCHECK(dirlen > buflen);
strcpy(buf, dir);
- free(dir);
+ xfree(dir);
SET_EXTERNAL_ENCODING();
}
p = chompdirsep(skiproot(buf));
@@ -2708,7 +2708,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
dirlen = strlen(dir);
BUFCHECK(dirlen > buflen);
strcpy(buf, dir);
- free(dir);
+ xfree(dir);
SET_EXTERNAL_ENCODING();
}
#if defined DOSISH || defined __CYGWIN__
@@ -3726,7 +3726,7 @@ rb_stat_init(VALUE obj, VALUE fname)
rb_sys_fail(RSTRING_PTR(fname));
}
if (DATA_PTR(obj)) {
- free(DATA_PTR(obj));
+ xfree(DATA_PTR(obj));
DATA_PTR(obj) = NULL;
}
nst = ALLOC(struct stat);
@@ -3749,7 +3749,7 @@ rb_stat_init_copy(VALUE copy, VALUE orig)
rb_raise(rb_eTypeError, "wrong argument class");
}
if (DATA_PTR(copy)) {
- free(DATA_PTR(copy));
+ xfree(DATA_PTR(copy));
DATA_PTR(copy) = 0;
}
if (DATA_PTR(orig)) {
@@ -4373,7 +4373,7 @@ path_check_0(VALUE path, int execpath)
VALUE newpath;
newpath = rb_str_new2(buf);
- free(buf);
+ xfree(buf);
rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
diff --git a/gc.c b/gc.c
index 032f707..3da1827 100644
--- a/gc.c
+++ b/gc.c
@@ -476,6 +476,13 @@ rb_gc_disable(void)
VALUE rb_mGC;
void
+rb_register_mark_object(VALUE obj)
+{
+ VALUE ary = GET_THREAD()->vm->mark_object_ary;
+ rb_ary_push(ary, obj);
+}
+
+void
rb_gc_register_address(VALUE *addr)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -488,13 +495,6 @@ rb_gc_register_address(VALUE *addr)
}
void
-rb_register_mark_object(VALUE obj)
-{
- VALUE ary = GET_THREAD()->vm->mark_object_ary;
- rb_ary_push(ary, obj);
-}
-
-void
rb_gc_unregister_address(VALUE *addr)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -502,7 +502,7 @@ rb_gc_unregister_address(VALUE *addr)
if (tmp->varptr == addr) {
global_List = tmp->next;
- RUBY_CRITICAL(free(tmp));
+ xfree(tmp);
return;
}
while (tmp->next) {
@@ -510,7 +510,7 @@ rb_gc_unregister_address(VALUE *addr)
struct gc_list *t = tmp->next;
tmp->next = tmp->next->next;
- RUBY_CRITICAL(free(t));
+ xfree(t);
break;
}
tmp = tmp->next;
@@ -1457,7 +1457,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_OBJECT:
if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
RANY(obj)->as.object.as.heap.ivptr) {
- RUBY_CRITICAL(free(RANY(obj)->as.object.as.heap.ivptr));
+ xfree(RANY(obj)->as.object.as.heap.ivptr);
}
break;
case T_MODULE:
@@ -1470,7 +1470,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (RCLASS_IV_INDEX_TBL(obj)) {
st_free_table(RCLASS_IV_INDEX_TBL(obj));
}
- RUBY_CRITICAL(free(RANY(obj)->as.klass.ptr));
+ xfree(RANY(obj)->as.klass.ptr);
break;
case T_STRING:
rb_str_free(obj);
@@ -1488,13 +1488,13 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
onig_free(RANY(obj)->as.regexp.ptr);
}
if (RANY(obj)->as.regexp.str) {
- RUBY_CRITICAL(free(RANY(obj)->as.regexp.str));
+ xfree(RANY(obj)->as.regexp.str);
}
break;
case T_DATA:
if (DATA_PTR(obj)) {
if ((long)RANY(obj)->as.data.dfree == -1) {
- RUBY_CRITICAL(free(DATA_PTR(obj)));
+ xfree(DATA_PTR(obj));
}
else if (RANY(obj)->as.data.dfree) {
(*RANY(obj)->as.data.dfree)(DATA_PTR(obj));
@@ -1506,8 +1506,8 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
struct rmatch *rm = RANY(obj)->as.match.rmatch;
onig_region_free(&rm->regs, 0);
if (rm->char_offset)
- RUBY_CRITICAL(free(rm->char_offset));
- RUBY_CRITICAL(free(rm));
+ xfree(rm->char_offset);
+ xfree(rm);
}
break;
case T_FILE:
@@ -1527,18 +1527,18 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_BIGNUM:
if (!(RBASIC(obj)->flags & RBIGNUM_EMBED_FLAG) && RBIGNUM_DIGITS(obj)) {
- RUBY_CRITICAL(free(RBIGNUM_DIGITS(obj)));
+ xfree(RBIGNUM_DIGITS(obj));
}
break;
case T_NODE:
switch (nd_type(obj)) {
case NODE_SCOPE:
if (RANY(obj)->as.node.u1.tbl) {
- RUBY_CRITICAL(free(RANY(obj)->as.node.u1.tbl));
+ xfree(RANY(obj)->as.node.u1.tbl);
}
break;
case NODE_ALLOCA:
- RUBY_CRITICAL(free(RANY(obj)->as.node.u1.node));
+ xfree(RANY(obj)->as.node.u1.node);
break;
}
return; /* no need to free iv_tbl */
@@ -1546,7 +1546,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_STRUCT:
if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
RANY(obj)->as.rstruct.as.heap.ptr) {
- RUBY_CRITICAL(free(RANY(obj)->as.rstruct.as.heap.ptr));
+ xfree(RANY(obj)->as.rstruct.as.heap.ptr);
}
break;
@@ -2106,7 +2106,7 @@ rb_gc_call_finalizer_at_exit(void)
RANY(p)->as.basic.klass != rb_cThread) {
p->as.free.flags = 0;
if ((long)RANY(p)->as.data.dfree == -1) {
- RUBY_CRITICAL(free(DATA_PTR(p)));
+ xfree(DATA_PTR(p));
}
else if (RANY(p)->as.data.dfree) {
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
diff --git a/hash.c b/hash.c
index 4232cee..b5a0c68 100644
--- a/hash.c
+++ b/hash.c
@@ -1984,7 +1984,7 @@ ruby_setenv(const char *name, const char *value)
char **envp = origenviron;
while (*envp && *envp != environ[i]) envp++;
if (!*envp)
- free(environ[i]);
+ xfree(environ[i]);
if (!value) {
while (environ[i]) {
environ[i] = environ[i+1];
diff --git a/io.c b/io.c
index 40f9abf..27bfec1 100644
--- a/io.c
+++ b/io.c
@@ -18,6 +18,8 @@
#include <ctype.h>
#include <errno.h>
+#define free(x) xfree(x)
+
#if defined(DOSISH) || defined(__CYGWIN__)
#include <io.h>
#endif
diff --git a/load.c b/load.c
index f91768c..88db04b 100644
--- a/load.c
+++ b/load.c
@@ -372,7 +372,7 @@ load_unlock(const char *ftptr)
st_table *loading_tbl = get_loading_table();
if (st_delete(loading_tbl, &key, &data)) {
- free((char *)key);
+ xfree((char *)key);
rb_barrier_release((VALUE)data);
}
}
diff --git a/pack.c b/pack.c
index 5408f7e..59893e2 100644
--- a/pack.c
+++ b/pack.c
@@ -67,8 +67,8 @@ TOKEN_PASTE(swap,x)(xtype z) \
t[sizeof(xtype)-i-1] = s[i]; \
} \
r = *(xtype *)t; \
- free(t); \
- free(zp); \
+ xfree(t); \
+ xfree(zp); \
return r; \
}
diff --git a/proc.c b/proc.c
index f0934a5..864e8df 100644
--- a/proc.c
+++ b/proc.c
@@ -248,8 +248,7 @@ binding_alloc(VALUE klass)
{
VALUE obj;
rb_binding_t *bind;
- obj = Data_Make_Struct(klass, rb_binding_t,
- binding_mark, binding_free, bind);
+ obj = Data_Make_Struct(klass, rb_binding_t, binding_mark, binding_free, bind);
return obj;
}
@@ -869,8 +868,7 @@ method_unbind(VALUE obj)
Data_Get_Struct(obj, struct METHOD, orig);
method =
- Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free,
- data);
+ Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, -1, data);
data->oclass = orig->oclass;
data->recv = Qundef;
data->id = orig->id;
@@ -1135,8 +1133,7 @@ method_clone(VALUE self)
struct METHOD *orig, *data;
Data_Get_Struct(self, struct METHOD, orig);
- clone =
- Data_Make_Struct(CLASS_OF(self), struct METHOD, bm_mark, free, data);
+ clone = Data_Make_Struct(CLASS_OF(self), struct METHOD, bm_mark, -1, data);
CLONESETUP(clone, self);
*data = *orig;
@@ -1299,7 +1296,7 @@ umethod_bind(VALUE method, VALUE recv)
}
}
- method = Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, free, bound);
+ method = Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, -1, bound);
*bound = *data;
bound->recv = recv;
bound->rclass = CLASS_OF(recv);
diff --git a/random.c b/random.c
index 8487277..d0849eb 100644
--- a/random.c
+++ b/random.c
@@ -255,7 +255,7 @@ rand_init(VALUE vseed)
}
old = saved_seed;
saved_seed = seed;
- free(buf);
+ xfree(buf);
return old;
}
diff --git a/re.c b/re.c
index 51809f5..035e248 100644
--- a/re.c
+++ b/re.c
@@ -2296,7 +2296,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
if (FL_TEST(obj, REG_LITERAL))
rb_raise(rb_eSecurityError, "can't modify literal regexp");
if (re->ptr) onig_free(re->ptr);
- if (re->str) free(re->str);
+ if (re->str) xfree(re->str);
re->ptr = 0;
re->str = 0;
diff --git a/ruby.c b/ruby.c
index f0aee7a..de347c9 100644
--- a/ruby.c
+++ b/ruby.c
@@ -455,8 +455,8 @@ require_libraries(void)
while (list) {
VALUE feature = rb_str_new2(list->name);
tmp = list->next;
- free(list->name);
- free(list);
+ xfree(list->name);
+ xfree(list);
list = tmp;
rb_funcall2(rb_vm_top_self(), require, 1, &feature);
}
diff --git a/st.c b/st.c
index 5ddb6d9..a51d7cf 100644
--- a/st.c
+++ b/st.c
@@ -63,6 +63,7 @@ static void rehash(st_table *);
#ifdef RUBY
#define malloc xmalloc
#define calloc xcalloc
+#define free(x) xfree(x)
#endif
#define alloc(type) (type*)malloc((size_t)sizeof(type))
diff --git a/string.c b/string.c
index 404abe0..68a4c55 100644
--- a/string.c
+++ b/string.c
@@ -609,7 +609,7 @@ rb_str_shared_replace(VALUE str, VALUE str2)
return;
}
if (!STR_SHARED_P(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
+ xfree(RSTRING_PTR(str));
}
STR_SET_NOEMBED(str);
STR_UNSET_NOCAPA(str);
@@ -3405,7 +3405,7 @@ rb_str_replace(VALUE str, VALUE str2)
}
if (STR_SHARED_P(str2)) {
if (str_independent(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
+ xfree(RSTRING_PTR(str));
}
STR_SET_NOEMBED(str);
RSTRING(str)->as.heap.len = len;
@@ -3439,7 +3439,7 @@ rb_str_clear(VALUE str)
{
/* rb_str_modify() */ /* no need for str_make_independent */
if (str_independent(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
+ xfree(RSTRING_PTR(str));
}
STR_SET_EMBED(str);
STR_SET_EMBED_LEN(str, 0);
@@ -4425,7 +4425,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
t += tlen;
}
if (!STR_EMBED_P(str)) {
- free(RSTRING(str)->as.heap.ptr);
+ xfree(RSTRING(str)->as.heap.ptr);
}
*t = '\0';
RSTRING(str)->as.heap.ptr = buf;
diff --git a/thread.c b/thread.c
index 87535c2..298d1c1 100644
--- a/thread.c
+++ b/thread.c
@@ -1712,7 +1712,7 @@ rb_fd_init(volatile rb_fdset_t *fds)
void
rb_fd_term(rb_fdset_t *fds)
{
- if (fds->fdset) free(fds->fdset);
+ if (fds->fdset) xfree(fds->fdset);
fds->maxfd = 0;
fds->fdset = 0;
}
@@ -2129,7 +2129,7 @@ thgroup_s_alloc(VALUE klass)
VALUE group;
struct thgroup *data;
- group = Data_Make_Struct(klass, struct thgroup, 0, free, data);
+ group = Data_Make_Struct(klass, struct thgroup, 0, -1, data);
data->enclosed = 0;
data->group = group;
@@ -2668,8 +2668,7 @@ barrier_alloc(VALUE klass)
VALUE volatile obj;
rb_barrier_t *barrier;
- obj = Data_Make_Struct(klass, rb_barrier_t,
- barrier_mark, barrier_free, barrier);
+ obj = Data_Make_Struct(klass, rb_barrier_t, barrier_mark, barrier_free, barrier);
barrier->owner = GET_THREAD();
barrier->waiting = 0;
barrier->tail = &barrier->waiting;
diff --git a/thread_pthread.c b/thread_pthread.c
index e5a6566..cece65c 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -247,7 +247,7 @@ register_cached_thread_and_wait(void)
}
}
- free(entry);
+ free(entry); /* ok */
pthread_cond_destroy(&cond);
}
pthread_mutex_unlock(&thread_cache_lock);
@@ -541,7 +541,7 @@ remove_signal_thread_list(rb_thread_t *th)
}
th->native_thread_data.signal_thread_list = 0;
list->th = 0;
- free(list);
+ free(list); /* ok */
});
}
else {
diff --git a/time.c b/time.c
index e4e4ee2..f6e9724 100644
--- a/time.c
+++ b/time.c
@@ -39,7 +39,7 @@ struct time_object {
static void
time_free(void *tobj)
{
- if (tobj) free(tobj);
+ if (tobj) xfree(tobj);
}
static VALUE
@@ -2028,7 +2028,7 @@ rb_strftime(char **buf, const char *format, struct tm *time)
* format string, it's not failing for lack of room.
*/
if (len > 0 || size >= 1024 * flen) return len;
- free(*buf);
+ xfree(*buf);
}
/* not reached */
}
@@ -2108,7 +2108,7 @@ time_strftime(VALUE time, VALUE format)
rb_str_cat(str, buf, len);
p += strlen(p);
if (buf != buffer) {
- free(buf);
+ xfree(buf);
buf = buffer;
}
for (fmt = p; p < pe && !*p; ++p);
@@ -2120,7 +2120,7 @@ time_strftime(VALUE time, VALUE format)
len = rb_strftime(&buf, RSTRING_PTR(format), &tobj->tm);
}
str = rb_str_new(buf, len);
- if (buf != buffer) free(buf);
+ if (buf != buffer) xfree(buf);
rb_enc_copy(str, format);
return str;
}
diff --git a/util.c b/util.c
index 125b991..b058f8b 100644
--- a/util.c
+++ b/util.c
@@ -748,7 +748,7 @@ ruby_getcwd(void)
while (!getcwd(buf, size)) {
if (errno != ERANGE) {
- free(buf);
+ xfree(buf);
rb_sys_fail("getcwd");
}
size *= 2;
@@ -761,7 +761,7 @@ ruby_getcwd(void)
char *buf = xmalloc(PATH_MAX+1);
if (!getwd(buf)) {
- free(buf);
+ xfree(buf);
rb_sys_fail("getwd");
}
#endif
diff --git a/variable.c b/variable.c
index 572c329..14cac18 100644
--- a/variable.c
+++ b/variable.c
@@ -564,7 +564,7 @@ remove_trace(struct global_variable *var)
next = trace->next;
if (next->removed) {
trace->next = next->next;
- free(next);
+ xfree(next);
}
else {
trace = next;
@@ -757,10 +757,10 @@ rb_alias_variable(ID name1, ID name2)
struct trace_var *trace = var->trace;
while (trace) {
struct trace_var *next = trace->next;
- free(trace);
+ xfree(trace);
trace = next;
}
- free(var);
+ xfree(var);
}
}
else {
diff --git a/version.h b/version.h
index aec5fe1..182a900 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-06-07"
+#define RUBY_RELEASE_DATE "2008-06-08"
#define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080607
+#define RUBY_RELEASE_CODE 20080608
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 7
+#define RUBY_RELEASE_DAY 8
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
diff --git a/vm.c b/vm.c
index 0194ea6..3ea6a65 100644
--- a/vm.c
+++ b/vm.c
@@ -1536,8 +1536,7 @@ thread_alloc(VALUE klass)
obj = Data_Wrap_Struct(klass, rb_thread_mark, thread_free, th);
#else
rb_thread_t *th;
- obj = Data_Make_Struct(klass, rb_thread_t,
- rb_thread_mark, thread_free, th);
+ obj = Data_Make_Struct(klass, rb_thread_t, rb_thread_mark, thread_free, th);
#endif
return obj;
}
@@ -1627,7 +1626,7 @@ nsdr(void)
for (i=0; i<n; i++) {
rb_ary_push(ary, rb_str_new2(syms[i]));
}
- free(syms);
+ free(syms); /* OK */
#endif
return ary;
}
@@ -1708,8 +1707,7 @@ Init_VM(void)
vm->self = Data_Wrap_Struct(rb_cVM, rb_vm_mark, vm_free, vm);
/* create main thread */
- th_self = th->self = Data_Wrap_Struct(rb_cThread, rb_thread_mark,
- thread_free, th);
+ th_self = th->self = Data_Wrap_Struct(rb_cThread, rb_thread_mark, thread_free, th);
vm->main_thread = th;
vm->running_thread = th;
th->vm = vm;