Skip to content
Snippets Groups Projects
Commit 7673f7ac authored by Craig Tiller's avatar Craig Tiller
Browse files

Change string format

parent 07f2e5f6
No related branches found
No related tags found
No related merge requests found
...@@ -73,12 +73,18 @@ static uint8_t next_byte(input_stream *inp) { ...@@ -73,12 +73,18 @@ static uint8_t next_byte(input_stream *inp) {
static void end(input_stream *inp) { inp->cur = inp->end; } static void end(input_stream *inp) { inp->cur = inp->end; }
static char *read_string(input_stream *inp) { static char *read_string(input_stream *inp) {
size_t len = next_byte(inp); char *str = NULL;
char *str = gpr_malloc(len + 1); size_t cap = 0;
for (size_t i = 0; i < len; i++) { size_t sz = 0;
str[i] = (char)next_byte(inp); char c;
} do {
str[len] = 0; 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; return str;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment