summaryrefslogtreecommitdiff
path: root/ext/dbm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dbm')
-rw-r--r--ext/dbm/dbm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index f7b4c8c..bbc3528 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -71,6 +71,21 @@ fdbm_close(obj)
return Qnil;
}
+static VALUE
+fdbm_closed(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+
+ Data_Get_Struct(obj, struct dbmdata, dbmp);
+ if (dbmp == 0)
+ return Qtrue;
+ if (dbmp->di_dbm == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
static VALUE fdbm_alloc _((VALUE));
static VALUE
fdbm_alloc(klass)
@@ -719,6 +734,7 @@ Init_dbm()
rb_define_method(rb_cDBM, "initialize", fdbm_initialize, -1);
rb_define_method(rb_cDBM, "close", fdbm_close, 0);
+ rb_define_method(rb_cDBM, "closed?", fdbm_closed, 0);
rb_define_method(rb_cDBM, "[]", fdbm_aref, 1);
rb_define_method(rb_cDBM, "fetch", fdbm_fetch_m, -1);
rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);