diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-05 04:09:05 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-06 03:45:10 +0200 |
commit | 0a45df1135e7244b4bc40c1d1c09ca80b920b35e (patch) | |
tree | 725b7494d98561bc8499f14c077cf2df252708b2 | |
parent | d2c1cda9f75c7e0244cc3a41f45965f28d3bb9ba (diff) | |
download | sparse-0a45df1135e7244b4bc40c1d1c09ca80b920b35e.tar.gz |
predef: simplify add_pre_buffer()
pre_buffer_begin & pre_buffer_end are the head and the tail of
a singly chained list. As such, it's slightly easier to not
keep a pointer on the last element but a pointer where the
next element should be written.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -173,7 +173,7 @@ void die(const char *fmt, ...) //////////////////////////////////////////////////////////////////////////////// static struct token *pre_buffer_begin = NULL; -static struct token *pre_buffer_end = NULL; +static struct token **pre_buffer_next = &pre_buffer_begin; void add_pre_buffer(const char *fmt, ...) { @@ -186,11 +186,8 @@ void add_pre_buffer(const char *fmt, ...) size = vsnprintf(buffer, sizeof(buffer), fmt, args); va_end(args); begin = tokenize_buffer(buffer, size, &end); - if (!pre_buffer_begin) - pre_buffer_begin = begin; - if (pre_buffer_end) - pre_buffer_end->next = begin; - pre_buffer_end = end; + *pre_buffer_next = begin; + pre_buffer_next = &end->next; } static void create_builtin_stream(void) |