From: Kazuhiro NISHIYAMA Date: 2008-11-26T15:41:47+09:00 Subject: [ruby-dev:37200] xfree or ruby_xfree 西山和広です。 trunkとruby_1_8のext/gdbm/gdbm.cのdiffをみたときにfreeとxfreeの 違いが気になったので、 http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=17017 の一部をバックポートしようかと思ったのですが、 xfreeとruby_xfreeはどういう基準で使い分けているのでしょうか? 以下、現状のパッチです。 trunkの方: Index: ext/curses/curses.c =================================================================== --- ext/curses/curses.c (revision 20364) +++ ext/curses/curses.c (working copy) @@ -94,7 +94,7 @@ { if (winp->window && winp->window != stdscr) delwin(winp->window); winp->window = 0; - free(winp); + xfree(winp); } static VALUE ruby_1_8の方: Index: ext/digest/digest.c =================================================================== --- ext/digest/digest.c (revision 20360) +++ ext/digest/digest.c (working copy) @@ -469,7 +469,7 @@ 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; } Index: ext/sdbm/init.c =================================================================== --- ext/sdbm/init.c (revision 20360) +++ ext/sdbm/init.c (working copy) @@ -46,7 +46,7 @@ { if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm); - free(dbmp); + xfree(dbmp); } static VALUE Index: ext/zlib/zlib.c =================================================================== --- ext/zlib/zlib.c (revision 20360) +++ ext/zlib/zlib.c (working copy) @@ -410,7 +410,7 @@ zlib_mem_free(opaque, address) voidpf opaque, address; { - free(address); + xfree(address); } static void @@ -837,7 +837,7 @@ if (ZSTREAM_IS_READY(z)) { zstream_finalize(z); } - free(z); + xfree(z); } static VALUE @@ -1776,7 +1776,7 @@ } zstream_finalize(z); } - free(gz); + xfree(gz); } static VALUE Index: ext/curses/curses.c =================================================================== --- ext/curses/curses.c (revision 20360) +++ ext/curses/curses.c (working copy) @@ -95,7 +95,7 @@ { if (winp->window && winp->window != stdscr) delwin(winp->window); winp->window = 0; - free(winp); + xfree(winp); } static VALUE @@ -672,7 +672,7 @@ curses_mousedata_free(struct mousedata *mdata) { if (mdata->mevent) - free(mdata->mevent); + xfree(mdata->mevent); } static VALUE Index: ext/openssl/ossl_hmac.c =================================================================== --- ext/openssl/ossl_hmac.c (revision 20360) +++ ext/openssl/ossl_hmac.c (working copy) @@ -42,7 +42,7 @@ ossl_hmac_free(HMAC_CTX *ctx) { HMAC_CTX_cleanup(ctx); - free(ctx); + xfree(ctx); } static VALUE Index: ext/openssl/ossl_cipher.c =================================================================== --- ext/openssl/ossl_cipher.c (revision 20360) +++ ext/openssl/ossl_cipher.c (working copy) @@ -67,7 +67,7 @@ { if (ctx) { EVP_CIPHER_CTX_cleanup(ctx); - free(ctx); + xfree(ctx); } } Index: ext/openssl/ossl_pkey_ec.c =================================================================== --- ext/openssl/ossl_pkey_ec.c (revision 20360) +++ ext/openssl/ossl_pkey_ec.c (working copy) @@ -695,7 +695,7 @@ { if (!ec_group->dont_free && ec_group->group) EC_GROUP_clear_free(ec_group->group); - free(ec_group); + xfree(ec_group); } static VALUE ossl_ec_group_alloc(VALUE klass) @@ -1201,7 +1201,7 @@ { if (!ec_point->dont_free && ec_point->point) EC_POINT_clear_free(ec_point->point); - free(ec_point); + xfree(ec_point); } static VALUE ossl_ec_point_alloc(VALUE klass) Index: ext/dbm/dbm.c =================================================================== --- ext/dbm/dbm.c (revision 20360) +++ ext/dbm/dbm.c (working copy) @@ -54,7 +54,7 @@ { if (dbmp) { if (dbmp->di_dbm) dbm_close(dbmp->di_dbm); - free(dbmp); + xfree(dbmp); } } Index: ext/gdbm/gdbm.c =================================================================== --- ext/gdbm/gdbm.c (revision 20361) +++ ext/gdbm/gdbm.c (working copy) @@ -113,7 +113,7 @@ { if (dbmp) { if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm); - free(dbmp); + xfree(dbmp); } } Index: ext/strscan/strscan.c =================================================================== --- ext/strscan/strscan.c (revision 20360) +++ ext/strscan/strscan.c (working copy) @@ -157,7 +157,7 @@ strscan_free(struct strscanner *p) { re_free_registers(&(p->regs)); - free(p); + xfree(p); } static VALUE -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA)