Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: runtime/vm/snapshot_test.cc

Issue 2449013003: Don't allocate on the Dart heap during Bigint::ToCString(). (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot_test.cc
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index adc8e1ffd2c297f0c3d21d3262e549200dd6a92b..39450e441dd1469e6a5e86764acfe44d4b38b507 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -377,11 +377,6 @@ TEST_CASE(SerializeFalse) {
}
-static uword allocator(intptr_t size) {
- return reinterpret_cast<uword>(malloc(size));
-}
-
-
TEST_CASE(SerializeCapability) {
// Write snapshot with object content.
const Capability& capability = Capability::Handle(Capability::New(12345));
@@ -425,7 +420,8 @@ TEST_CASE(SerializeBigint) {
Bigint& obj = Bigint::Handle();
obj ^= reader.ReadObject();
- EXPECT_STREQ(bigint.ToHexCString(allocator), obj.ToHexCString(allocator));
+ Zone* zone = Thread::Current()->zone();
+ EXPECT_STREQ(bigint.ToHexCString(zone), obj.ToHexCString(zone));
// Read object back from the snapshot into a C structure.
ApiNativeScope scope;
@@ -455,11 +451,9 @@ Dart_CObject* SerializeAndDeserializeBigint(const Bigint& bigint) {
MessageSnapshotReader reader(buffer, buffer_len, thread);
Bigint& serialized_bigint = Bigint::Handle();
serialized_bigint ^= reader.ReadObject();
- const char* str1 = bigint.ToHexCString(allocator);
- const char* str2 = serialized_bigint.ToHexCString(allocator);
+ const char* str1 = bigint.ToHexCString(thread->zone());
+ const char* str2 = serialized_bigint.ToHexCString(thread->zone());
EXPECT_STREQ(str1, str2);
- free(const_cast<char*>(str1));
- free(const_cast<char*>(str2));
}
// Read object back from the snapshot into a C structure.
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698