summaryrefslogtreecommitdiff
path: root/ext/gdbm/gdbm.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-13 08:19:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-13 08:19:09 +0000
commitd8c75ddad376abf83a4d6dd9d4c8eb1736db497c (patch)
tree12ebace8954f29cfbc70bc55800cfa1e01dcc5b0 /ext/gdbm/gdbm.c
parenta59c599209a11d4ab0dc0d7626ab3d5ca43a78c2 (diff)
* time.c (time_new_internal): avoid loop to calculate negative
div, mod. * time.c (time_cmp): should handle Bignums. * array.c (rb_ary_pop): should ELTS_SHARED flag check before REALLOC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/gdbm/gdbm.c')
-rw-r--r--ext/gdbm/gdbm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 0fa13a5e67..eddeb11f8e 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -159,13 +159,13 @@ rb_gdbm_fetch(dbm, key)
datum key;
{
datum val;
- VALUE str = rb_obj_alloc(rb_cString);
+ VALUE str;
val = gdbm_fetch(dbm, key);
if (val.dptr == 0)
return Qnil;
- RSTRING(str)->ptr = 0;
+ str = rb_obj_alloc(rb_cString);
RSTRING(str)->len = val.dsize;
RSTRING(str)->aux.capa = val.dsize;
RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1);
@@ -206,13 +206,13 @@ rb_gdbm_firstkey(dbm)
GDBM_FILE dbm;
{
datum key;
- VALUE str = rb_obj_alloc(rb_cString);
+ VALUE str;
key = gdbm_firstkey(dbm);
if (key.dptr == 0)
return Qnil;
- RSTRING(str)->ptr = 0;
+ str = rb_obj_alloc(rb_cString);
RSTRING(str)->len = key.dsize;
RSTRING(str)->aux.capa = key.dsize;
RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1);
@@ -228,7 +228,7 @@ rb_gdbm_nextkey(dbm, keystr)
VALUE keystr;
{
datum key, key2;
- VALUE str = rb_obj_alloc(rb_cString);
+ VALUE str;
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -236,7 +236,7 @@ rb_gdbm_nextkey(dbm, keystr)
if (key2.dptr == 0)
return Qnil;
- RSTRING(str)->ptr = 0;
+ str = rb_obj_alloc(rb_cString);
RSTRING(str)->len = key2.dsize;
RSTRING(str)->aux.capa = key2.dsize;
RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);