aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/gdbm/gdbm.c39
-rw-r--r--ext/pty/pty.c9
-rw-r--r--ext/socket/socket.c5
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