* 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
This commit is contained in:
ko1 2008-06-08 10:01:40 +00:00
Родитель 4a7311e129
Коммит 72ba13aa8e
40 изменённых файлов: 133 добавлений и 118 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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()) {

Просмотреть файл

@ -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 {

3
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;

41
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);

2
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"

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -635,7 +635,7 @@ static void
curses_mousedata_free(struct mousedata *mdata)
{
if (mdata->mevent)
free(mdata->mevent);
xfree(mdata->mevent);
}
static VALUE

Просмотреть файл

@ -52,7 +52,7 @@ free_dbm(struct dbmdata *dbmp)
{
if (dbmp) {
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
free(dbmp);
xfree(dbmp);
}
}

Просмотреть файл

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

Просмотреть файл

@ -110,7 +110,7 @@ free_dbm(struct dbmdata *dbmp)
{
if (dbmp) {
if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
free(dbmp);
xfree(dbmp);
}
}

Просмотреть файл

@ -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)

Просмотреть файл

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

Просмотреть файл

@ -67,7 +67,7 @@ ossl_cipher_free(EVP_CIPHER_CTX *ctx)
{
if (ctx) {
EVP_CIPHER_CTX_cleanup(ctx);
free(ctx);
ruby_xfree(ctx);
}
}

Просмотреть файл

@ -42,7 +42,7 @@ static void
ossl_hmac_free(HMAC_CTX *ctx)
{
HMAC_CTX_cleanup(ctx);
free(ctx);
ruby_xfree(ctx);
}
static VALUE

Просмотреть файл

@ -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)

Просмотреть файл

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

Просмотреть файл

@ -166,7 +166,7 @@ static void
strscan_free(struct strscanner *p)
{
onig_region_free(&(p->regs), 0);
free(p);
ruby_xfree(p);
}
static VALUE

Просмотреть файл

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

18
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);

40
gc.c
Просмотреть файл

@ -475,6 +475,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)
{
@ -487,13 +494,6 @@ rb_gc_register_address(VALUE *addr)
global_List = tmp;
}
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)
{
@ -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));

2
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];

2
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

2
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);
}
}

4
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; \
}

11
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);

Просмотреть файл

@ -255,7 +255,7 @@ rand_init(VALUE vseed)
}
old = saved_seed;
saved_seed = seed;
free(buf);
xfree(buf);
return old;
}

2
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;

4
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);
}

1
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))

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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 {

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

4
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

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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[];

8
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;