Chromium Code Reviews| Index: runtime/vm/bigint_operations.cc |
| =================================================================== |
| --- runtime/vm/bigint_operations.cc (revision 1042) |
| +++ runtime/vm/bigint_operations.cc (working copy) |
| @@ -220,6 +220,23 @@ |
| } |
| +const char* BigintOperations::ToDecCString(const Bigint& bigint, |
| + uword (*allocator)(intptr_t size)) { |
| + return ToDecCString(bigint.BNAddr(), allocator); |
| +} |
| + |
| + |
| +const char* BigintOperations::ToDecCString(const BIGNUM *bn, |
| + uword (*allocator)(intptr_t size)) { |
| + char* str = BN_bn2dec(bn); |
|
cshapiro
2011/11/02 00:19:01
BN has historically used an inefficient algorithm
sra1
2011/11/02 03:10:23
It might be fun to write the b^(n*2^i) algorithm i
|
| + intptr_t length = strlen(str) + 1; // '\0'-terminated. |
| + char* result = reinterpret_cast<char*>(allocator(length)); |
| + memmove(result, str, length); |
| + OPENSSL_free(str); |
| + return result; |
| +} |
| + |
| + |
| const char* BigintOperations::ToHexCString(const Bigint& bigint, |
| uword (*allocator)(intptr_t size)) { |
| return ToHexCString(bigint.BNAddr(), allocator); |