Modified: MacRuby/trunk/ext/digest/bubblebabble/bubblebabble.c (3779 => 3780)
--- 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 (3779 => 3780)
--- 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;
}