summaryrefslogtreecommitdiff
path: root/tests/pb
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2016-04-19 14:57:31 -0700
committerJoshua Haberman <jhaberman@gmail.com>2016-04-19 14:57:31 -0700
commit68bc62a7fa5febbf5c8ab2fe8f6171121d18690f (patch)
treecd40e0a0151a977627559b1fbbbac9250c8bba64 /tests/pb
parent04786dc2b3c68c8449b19fa2d12bd929f9813155 (diff)
Split upb::Arena/upb::Allocator from upb::Environment. (#58)
* Split upb::Arena/upb::Allocator from upb::Environment. This will allow arenas and allocators to be used independently of environments, which will be important for an upcoming change (a message representation). Overall this design feels cleaner that the previous Environment/SeededAllocator design. As part of this change, moved all allocations in upb to use a global allocator instead of hard-coding malloc/free. This will allow injecting OOM faults for more robust testing. One place that doesn't use the global allocator is the tracked ref code. Instead of its previous approach of CHECK_OOM() after every malloc() or table insert, it simply uses an allocator that does this automatically. I moved Allocator/Arena/Environment into upb.h. This seems principled since these are the only types in upb whose size is directly exposed to users, since they form the basis of memory allocation strategy. * Cleaned up some header includes and fixed more malloc -> upb_gmalloc(). * Changes from PR review. * Don't use UINTPTR_MAX or UINT64_MAX. * Punt on adding line/file for now. * We actually can't store (uint64_t)-1, update comment and test.
Diffstat (limited to 'tests/pb')
-rw-r--r--tests/pb/test_encoder.cc5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/pb/test_encoder.cc b/tests/pb/test_encoder.cc
index 6219e08..6c20e27 100644
--- a/tests/pb/test_encoder.cc
+++ b/tests/pb/test_encoder.cc
@@ -26,10 +26,7 @@ void test_pb_roundtrip() {
upb::pb::DecoderMethod::New(
upb::pb::DecoderMethodOptions(encoder_handlers.get())));
- char buf[512];
- upb::SeededAllocator alloc(buf, sizeof(buf));
- upb::Environment env;
- env.SetAllocator(&alloc);
+ upb::InlinedEnvironment<512> env;
std::string input = read_string("upb/descriptor/descriptor.pb");
std::string output;
upb::StringSink string_sink(&output);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback