summaryrefslogtreecommitdiff
path: root/ext/gdbm
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-24 06:00:03 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-24 06:00:03 +0000
commitf3376759aba9921ea0d995bc459c4c3b18135c5e (patch)
tree9c2fab7d645750261eec5efa9a7ed746404b96ce /ext/gdbm
parent53178fc7db9f899dfdac4f67ace9f72d80d4b50b (diff)
cleanup for curses, gdbm [ruby-core:502], [ruby-core:503]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/gdbm')
-rw-r--r--ext/gdbm/gdbm.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index d30f5de..9acbf04 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -36,11 +36,11 @@ closed_dbm()
rb_raise(rb_eRuntimeError, "closed GDBM file");
}
-#define GetDBM(obj, dbmp) {\
+#define GetDBM(obj, dbmp) do {\
Data_Get_Struct(obj, struct dbmdata, dbmp);\
if (dbmp == 0) closed_dbm();\
if (dbmp->di_dbm == 0) closed_dbm();\
-}
+} while (0)
static void
free_dbm(dbmp)
@@ -66,14 +66,12 @@ fgdbm_close(obj)
}
static VALUE
-fgdbm_s_new(argc, argv, klass)
+fgdbm_s_alloc(klass)
int argc;
VALUE *argv;
VALUE klass;
{
- VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
- rb_obj_call_init(obj, argc, argv);
- return obj;
+ return Data_Wrap_Struct(klass, 0, free_dbm, 0);
}
static VALUE
@@ -125,6 +123,7 @@ fgdbm_initialize(argc, argv, obj)
}
dbmp = ALLOC(struct dbmdata);
+ free_dbm(DATA_PTR(obj));
DATA_PTR(obj) = dbmp;
dbmp->di_dbm = dbm;
dbmp->di_size = -1;
@@ -924,7 +923,7 @@ Init_gdbm()
rb_eGDBMFatalError = rb_define_class("GDBMFatalError", rb_eException);
rb_include_module(rb_cGDBM, rb_mEnumerable);
- rb_define_singleton_method(rb_cGDBM, "new", fgdbm_s_new, -1);
+ rb_define_singleton_method(rb_cGDBM, "allocate", fgdbm_s_alloc, 0);
rb_define_singleton_method(rb_cGDBM, "open", fgdbm_s_open, -1);
rb_define_method(rb_cGDBM, "initialize", fgdbm_initialize, -1);