[PATCH v2 1/4] multi-buffer for idents

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

 



Currently, show_indent() use a single static buffer. It thus
can't be used like: printf("%s %s", show_ident(a), show_ident(b));

Fix this by using multiple buffers like done for show_pseudo()
and others.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 tokenize.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tokenize.c b/tokenize.c
index e98684ec5..01fbb9b35 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -88,9 +88,13 @@ const char *show_special(int val)
 
 const char *show_ident(const struct ident *ident)
 {
-	static char buffer[256];
+	static char buff[2][256];
+	static int n;
+	char *buffer;
+
 	if (!ident)
 		return "<noident>";
+	buffer = buff[2 & ++n];
 	sprintf(buffer, "%.*s", ident->len, ident->name);
 	return buffer;
 }
-- 
2.19.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