summaryrefslogtreecommitdiff
path: root/ext/sdbm/init.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:30:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:30:33 +0000
commit25c50cd193d89ad0737219142bab191f12b8abe8 (patch)
treea14ada29405880c7f56c615067b6600815f54334 /ext/sdbm/init.c
parent22f249ebd7a142faacdf5edd7e196bd2149feae5 (diff)
* ruby.h (struct RString): embed small strings.
(RSTRING_LEN): defined for accessing string members. (RSTRING_PTR): ditto. * string.c: use RSTRING_LEN and RSTRING_PTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/sdbm/init.c')
-rw-r--r--ext/sdbm/init.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 8eccbcc..758d737 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -101,15 +101,15 @@ fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
dbm = 0;
if (mode >= 0)
- dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode);
if (!dbm)
- dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, 0);
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDWR, 0);
if (!dbm)
- dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDONLY, 0);
if (!dbm) {
if (mode == -1) return Qnil;
- rb_sys_fail(RSTRING(file)->ptr);
+ rb_sys_fail(RSTRING_PTR(file));
}
dbmp = ALLOC(struct dbmdata);
@@ -144,8 +144,8 @@ fsdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING(keystr)->ptr;
- key.dsize = RSTRING(keystr)->len;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LEN(keystr);
GetDBM2(obj, dbmp, dbm);
value = sdbm_fetch(dbm, key);
@@ -184,14 +184,14 @@ fsdbm_index(VALUE obj, VALUE valstr)
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING(valstr)->ptr;
- val.dsize = RSTRING(valstr)->len;
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LEN(valstr);
GetDBM2(obj, dbmp, dbm);
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
- if (val.dsize == RSTRING(valstr)->len &&
- memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
+ if (val.dsize == RSTRING_LEN(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
return rb_tainted_str_new(key.dptr, key.dsize);
}
return Qnil;
@@ -251,8 +251,8 @@ fsdbm_delete(VALUE obj, VALUE keystr)
fdbm_modify(obj);
StringValue(keystr);
- key.dptr = RSTRING(keystr)->ptr;
- key.dsize = RSTRING(keystr)->len;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LEN(keystr);
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
@@ -326,8 +326,8 @@ fsdbm_delete_if(VALUE obj)
for (i = 0; i < RARRAY(ary)->len; i++) {
keystr = RARRAY(ary)->ptr[i];
StringValue(keystr);
- key.dptr = RSTRING(keystr)->ptr;
- key.dsize = RSTRING(keystr)->len;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LEN(keystr);
if (sdbm_delete(dbm, key)) {
rb_raise(rb_eDBMError, "sdbm_delete failed");
}
@@ -393,11 +393,11 @@ fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
StringValue(keystr);
StringValue(valstr);
- key.dptr = RSTRING(keystr)->ptr;
- key.dsize = RSTRING(keystr)->len;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LEN(keystr);
- val.dptr = RSTRING(valstr)->ptr;
- val.dsize = RSTRING(valstr)->len;
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LEN(valstr);
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
@@ -574,8 +574,8 @@ fsdbm_has_key(VALUE obj, VALUE keystr)
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING(keystr)->ptr;
- key.dsize = RSTRING(keystr)->len;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LEN(keystr);
GetDBM2(obj, dbmp, dbm);
val = sdbm_fetch(dbm, key);
@@ -591,14 +591,14 @@ fsdbm_has_value(VALUE obj, VALUE valstr)
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING(valstr)->ptr;
- val.dsize = RSTRING(valstr)->len;
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LEN(valstr);
GetDBM2(obj, dbmp, dbm);
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
- if (val.dsize == RSTRING(valstr)->len &&
- memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
+ if (val.dsize == RSTRING_LEN(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
return Qtrue;
}
return Qfalse;