[PATCH] predef: simplify add_pre_buffer()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 lib.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib.c b/lib.c
index e56788260cb7..863900b54c3c 100644
--- a/lib.c
+++ b/lib.c
@@ -248,7 +248,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;
 
 int Waddress = 0;
 int Waddress_space = 1;
@@ -348,11 +348,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;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-- 
2.27.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux