summaryrefslogtreecommitdiff
path: root/ext/digest/digest.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/digest/digest.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/digest/digest.c')
-rw-r--r--ext/digest/digest.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 906ea18..9d3492a 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -72,10 +72,10 @@ rb_digest_base_s_digest(VALUE klass, VALUE str)
Data_Get_Struct(obj, void, pctx);
StringValue(str);
- algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+ algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
str = rb_str_new(0, algo->digest_len);
- algo->final_func(RSTRING(str)->ptr, pctx);
+ algo->final_func(RSTRING_PTR(str), pctx);
return str;
}
@@ -91,10 +91,10 @@ rb_digest_base_s_hexdigest(VALUE klass, VALUE str)
Data_Get_Struct(obj, void, pctx);
StringValue(str);
- algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+ algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
str = rb_str_new(0, algo->digest_len * 2);
- algo->end_func(pctx, RSTRING(str)->ptr);
+ algo->end_func(pctx, RSTRING_PTR(str));
return str;
}
@@ -128,7 +128,7 @@ rb_digest_base_update(VALUE self, VALUE str)
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx);
- algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+ algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
return self;
}
@@ -162,7 +162,7 @@ rb_digest_base_digest(VALUE self)
pctx2 = xmalloc(len);
memcpy(pctx2, pctx1, len);
- algo->final_func(RSTRING(str)->ptr, pctx2);
+ algo->final_func(RSTRING_PTR(str), pctx2);
free(pctx2);
return str;
@@ -185,7 +185,7 @@ rb_digest_base_hexdigest(VALUE self)
pctx2 = xmalloc(len);
memcpy(pctx2, pctx1, len);
- algo->end_func(pctx2, RSTRING(str)->ptr);
+ algo->end_func(pctx2, RSTRING_PTR(str));
free(pctx2);
return str;
@@ -213,12 +213,12 @@ rb_digest_base_equal(VALUE self, VALUE other)
StringValue(other);
str2 = other;
- if (RSTRING(str2)->len == algo->digest_len)
+ if (RSTRING_LEN(str2) == algo->digest_len)
str1 = rb_digest_base_digest(self);
else
str1 = rb_digest_base_hexdigest(self);
- if (RSTRING(str1)->len == RSTRING(str2)->len
+ if (RSTRING_LEN(str1) == RSTRING_LEN(str2)
&& rb_str_cmp(str1, str2) == 0)
return Qtrue;