diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-03 07:19:19 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-03 07:19:19 +0000 |
commit | 1fe40b7cc5e92105f636d670d77b059fe4a4c50b (patch) | |
tree | 02dfc7bab198fc494d9d4f1f3bf1072d292fed66 /ext/gdbm/gdbm.c | |
parent | d902111a57dfcf3c9b017b0ebd1b49f19142168c (diff) | |
download | ruby-1fe40b7cc5e92105f636d670d77b059fe4a4c50b.tar.gz |
* marshal.c (r_object): better allocation type check for
TYPE_UCLASS. usage of allocation framework is disabled for now.
* variable.c (rb_class_path): Module may have subclass.
* string.c (rb_str_update): should maintain original negative
offset.
* string.c (rb_str_subpat_set): ditto
* string.c (rb_str_aset): ditto.
* re.c (rb_reg_nth_match): should check negative nth.
* re.c (rb_reg_nth_defined): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/gdbm/gdbm.c')
-rw-r--r-- | ext/gdbm/gdbm.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index f9a02e44eb..1e76a28ca8 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -159,18 +159,17 @@ rb_gdbm_fetch(dbm, key) datum key; { datum val; - NEWOBJ(str, struct RString); - OBJSETUP(str, rb_cString, T_STRING); + VALUE str = rb_obj_alloc(rb_cString); val = gdbm_fetch(dbm, key); if (val.dptr == 0) return Qnil; - str->ptr = 0; - str->len = val.dsize; - str->orig = 0; - str->ptr = REALLOC_N(val.dptr,char,val.dsize+1); - str->ptr[str->len] = '\0'; + RSTRING(str)->ptr = 0; + RSTRING(str)->len = val.dsize; + RSTRING(str)->orig = 0; + RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1); + RSTRING(str)->ptr[str->len] = '\0'; OBJ_TAINT(str); return (VALUE)str; @@ -207,18 +206,17 @@ rb_gdbm_firstkey(dbm) GDBM_FILE dbm; { datum key; - NEWOBJ(str, struct RString); - OBJSETUP(str, rb_cString, T_STRING); + VALUE str = rb_obj_alloc(rb_cString); key = gdbm_firstkey(dbm); if (key.dptr == 0) return Qnil; - str->ptr = 0; - str->len = key.dsize; - str->orig = 0; - str->ptr = REALLOC_N(key.dptr,char,key.dsize+1); - str->ptr[str->len] = '\0'; + RSTRING(str)->ptr = 0; + RSTRING(str)->len = key.dsize; + RSTRING(str)->orig = 0; + RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1); + RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; OBJ_TAINT(str); return (VALUE)str; @@ -230,8 +228,7 @@ rb_gdbm_nextkey(dbm, keystr) VALUE keystr; { datum key, key2; - NEWOBJ(str, struct RString); - OBJSETUP(str, rb_cString, T_STRING); + VALUE str = rb_obj_alloc(rb_cString); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; @@ -239,11 +236,11 @@ rb_gdbm_nextkey(dbm, keystr) if (key2.dptr == 0) return Qnil; - str->ptr = 0; - str->len = key2.dsize; - str->orig = 0; - str->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1); - str->ptr[str->len] = '\0'; + RSTRING(str)->ptr = 0; + RSTRING(str)->len = key2.dsize; + RSTRING(str)->orig = 0; + RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1); + RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; OBJ_TAINT(str); return (VALUE)str; |