Commit 2f3ca807 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

When parsing from memory, use counted buffers instead of strings.

parent 8fc3c521
...@@ -923,25 +923,25 @@ parse_config_from_file(const char *filename, int *line_return) ...@@ -923,25 +923,25 @@ parse_config_from_file(const char *filename, int *line_return)
return rc; return rc;
} }
struct string_state { struct buf_state {
char *string; char *buf;
int n; int i, n;
}; };
static int static int
gnc_string(struct string_state *s) gnc_buf(struct buf_state *s)
{ {
if(s->string[s->n] == '\0') if(s->i < s->n)
return -1; return s->buf[s->i++];
else else
return s->string[s->n++]; return -1;
} }
int int
parse_config_from_string(char *string) parse_config_from_string(char *string)
{ {
struct string_state s = { string, 0 }; struct buf_state s = { string, 0, strlen(string) };
return parse_config((gnc_t)gnc_string, &s); return parse_config((gnc_t)gnc_buf, &s);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment