From: Bert Vermeulen Date: Mon, 18 Aug 2014 22:09:09 +0000 (+0200) Subject: input: sr_input_new() always allocates the instance buffer. X-Git-Tag: libsigrok-0.4.0~1109 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=57486a7528f8a646bbc6d22994a8f5effd3cacf9;p=libsigrok.git input: sr_input_new() always allocates the instance buffer. --- diff --git a/src/input/input.c b/src/input/input.c index 36f63e1d..16185aaa 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -270,12 +270,12 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, } if (in->module->init && in->module->init(in, new_opts) != SR_OK) { - g_hash_table_destroy(new_opts); g_free(in); in = NULL; } if (new_opts) g_hash_table_destroy(new_opts); + in->buf = g_string_sized_new(128); return in; } @@ -357,7 +357,7 @@ SR_API const struct sr_input *sr_input_scan_buffer(GString *buf) /* Found a matching module. */ in = sr_input_new(imod, NULL); - in->buf = g_string_new_len(buf->str, buf->len); + g_string_insert_len(in->buf, 0, buf->str, buf->len); break; } @@ -456,7 +456,7 @@ SR_API const struct sr_input *sr_input_scan_file(const char *filename) /* Found a matching module. */ in = sr_input_new(imod, NULL); - in->buf = g_string_new_len(buf->str, buf->len); + g_string_insert_len(in->buf, 0, buf->str, buf->len); break; } if (!in && buf)