diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-04-06 14:28:45 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2016-04-06 14:28:45 -0700 |
commit | f8c26358f0b87a9c90be3f038cdea5bdcae185a0 (patch) | |
tree | a51e3b278d368ebd4fc01b0fff68c8f3f0701299 /tests/pb | |
parent | e9d79d2441732264e2b990a5b2dc76d13724db07 (diff) |
Changes for PR comments.
Diffstat (limited to 'tests/pb')
-rw-r--r-- | tests/pb/test_encoder.cc | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/tests/pb/test_encoder.cc b/tests/pb/test_encoder.cc index 6dd10ba..6219e08 100644 --- a/tests/pb/test_encoder.cc +++ b/tests/pb/test_encoder.cc @@ -1,4 +1,5 @@ +#include "tests/test_util.h" #include "tests/upb_test.h" #include "upb/bindings/stdc++/string.h" #include "upb/descriptor/descriptor.upbdefs.h" @@ -6,26 +7,6 @@ #include "upb/pb/encoder.h" #include "upb/pb/glue.h" -static char *upb_readfile(const char *filename, size_t *len) { - long size; - char *buf; - FILE *f = fopen(filename, "rb"); - if(!f) return NULL; - if(fseek(f, 0, SEEK_END) != 0) goto error; - size = ftell(f); - if(size < 0) goto error; - if(fseek(f, 0, SEEK_SET) != 0) goto error; - buf = (char*)malloc(size + 1); - if(size && fread(buf, size, 1, f) != 1) goto error; - fclose(f); - if (len) *len = size; - return buf; - -error: - fclose(f); - return NULL; -} - std::string read_string(const char *filename) { size_t len; char *str = upb_readfile(filename, &len); |