aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-04-18 22:44:57 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-04-18 22:44:57 -0700
commit7673f7ac63d8bf7e18bdcd2888c5c57822ce938f (patch)
treefa95bc9a713ed6677dc1d7e516c1089ace17b8c1 /test/core
parent07f2e5f643dd2b0c80c426322f0db154e484698e (diff)
Change string format
Diffstat (limited to 'test/core')
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index 9f11e750c7..a914482588 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -73,12 +73,18 @@ static uint8_t next_byte(input_stream *inp) {
static void end(input_stream *inp) { inp->cur = inp->end; }
static char *read_string(input_stream *inp) {
- size_t len = next_byte(inp);
- char *str = gpr_malloc(len + 1);
- for (size_t i = 0; i < len; i++) {
- str[i] = (char)next_byte(inp);
- }
- str[len] = 0;
+ char *str = NULL;
+ size_t cap = 0;
+ size_t sz = 0;
+ char c;
+ do {
+ if (cap == sz) {
+ cap = GPR_MAX(3*cap/2, cap+8);
+ str = gpr_realloc(str, cap);
+ }
+ c = (char)next_byte(inp);
+ str[sz++] = c;
+ } while (c != 0);
return str;
}