[macruby-changes] [3780] MacRuby/trunk/ext/digest
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 16 17:30:34 PDT 2010
Revision: 3780
http://trac.macosforge.org/projects/ruby/changeset/3780
Author: lsansonetti at apple.com
Date: 2010-03-16 17:30:34 -0700 (Tue, 16 Mar 2010)
Log Message:
-----------
no longer returning binary strings, to mimic 1.9
Modified Paths:
--------------
MacRuby/trunk/ext/digest/bubblebabble/bubblebabble.c
MacRuby/trunk/ext/digest/digest.c
Modified: MacRuby/trunk/ext/digest/bubblebabble/bubblebabble.c
===================================================================
--- MacRuby/trunk/ext/digest/bubblebabble/bubblebabble.c 2010-03-17 00:26:47 UTC (rev 3779)
+++ MacRuby/trunk/ext/digest/bubblebabble/bubblebabble.c 2010-03-17 00:30:34 UTC (rev 3780)
@@ -74,7 +74,7 @@
p[j] = 'x';
- VALUE bstr = rb_bstr_new_with_data(p, p_len);
+ VALUE bstr = rb_str_new(p, p_len);
free(p);
return bstr;
}
Modified: MacRuby/trunk/ext/digest/digest.c
===================================================================
--- MacRuby/trunk/ext/digest/digest.c 2010-03-17 00:26:47 UTC (rev 3779)
+++ MacRuby/trunk/ext/digest/digest.c 2010-03-17 00:30:34 UTC (rev 3780)
@@ -37,7 +37,7 @@
const char *digest;
size_t digest_len;
int i;
- UInt8 *p;
+ char *p;
static const char hex[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'
@@ -52,7 +52,7 @@
}
const size_t p_len = digest_len * 2;
- p = (UInt8 *)malloc(p_len + 1);
+ p = malloc(p_len + 1);
for (i = 0; i < digest_len; i++) {
unsigned char byte = digest[i];
@@ -61,7 +61,7 @@
p[i + i + 1] = hex[byte & 0x0f];
}
- VALUE bstr = rb_bstr_new_with_data(p, p_len);
+ VALUE bstr = rb_str_new(p, p_len);
free(p);
return bstr;
}
@@ -535,20 +535,20 @@
{
rb_digest_metadata_t *algo;
void *pctx;
- VALUE str;
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx);
- str = rb_bstr_new();
- rb_bstr_resize(str, algo->digest_len);
- rb_bstr_set_length(str, algo->digest_len);
- algo->finish_func(pctx, rb_bstr_bytes(str));
+ assert(algo->digest_len > 0);
+ char *buf = (char *)malloc(algo->digest_len);
+ algo->finish_func(pctx, (unsigned char *)buf);
/* avoid potential coredump caused by use of a finished context */
algo->init_func(pctx);
+ VALUE str = rb_str_new(buf, algo->digest_len);
+ free(buf);
return str;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100316/9a749c4a/attachment.html>
More information about the macruby-changes
mailing list