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 | |
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')
-rw-r--r-- | ext/gdbm/gdbm.c | 39 | ||||
-rw-r--r-- | ext/pty/pty.c | 9 | ||||
-rw-r--r-- | ext/socket/socket.c | 5 |
3 files changed, 23 insertions, 30 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; diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 9d2fb52bcf..3bf100ef20 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -367,13 +367,10 @@ pty_getpty(self, shell) VALUE res, th; struct pty_info info; OpenFile *wfptr,*rfptr; - NEWOBJ(rport, struct RFile); - NEWOBJ(wport, struct RFile); + VALUE rport = rb_obj_alloc(rb_cFile); + VALUE wport = rb_obj_alloc(rb_cFile); - OBJSETUP(rport, rb_cFile, T_FILE); MakeOpenFile(rport, rfptr); - - OBJSETUP(wport, rb_cFile, T_FILE); MakeOpenFile(wport, wfptr); establishShell(RSTRING(shell)->ptr,&info); @@ -399,7 +396,7 @@ pty_getpty(self, shell) return res; } else { - return (VALUE)res; + return res; } } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 9527cf3da1..5b7d8ebefb 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -177,8 +177,7 @@ sock_new(class, fd) int fd; { OpenFile *fp; - NEWOBJ(sock, struct RFile); - OBJSETUP(sock, class, T_FILE); + VALUE sock = rb_obj_alloc(class); MakeOpenFile(sock, fp); fp->f = rb_fdopen(fd, "r"); @@ -190,7 +189,7 @@ sock_new(class, fd) fp->mode = FMODE_READWRITE; rb_io_synchronized(fp); - return (VALUE)sock; + return sock; } static VALUE |