[PATCH] set initial length of string to 0 instead of 64

Biancaa Ramesh posted 1 patch 13 hours ago
scripts/kconfig/util.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
[PATCH] set initial length of string to 0 instead of 64
Posted by Biancaa Ramesh 13 hours ago
Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
---
 scripts/kconfig/util.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 176ec03bb3f0..f55e3ce496e1 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -64,13 +64,14 @@ const char *file_lookup(const char *name)
 struct gstr str_new(void)
 {
 	struct gstr gs;
-	gs.s = xmalloc(sizeof(char) * 64);
-	gs.len = 64;
+	gs.s = xmalloc(64);   // allocate buffer
+	gs.len = 0;           // string is empty
 	gs.max_width = 0;
-	strscpy(gs.s, "\0");
+	gs.s[0] = '\0';       // initialize as empty string
 	return gs;
 }
 
+
 /* Free storage for growable string */
 void str_free(struct gstr *gs)
 {
-- 
2.43.0


-- 
::DISCLAIMER::

---------------------------------------------------------------------
The 
contents of this e-mail and any attachment(s) are confidential and
intended 
for the named recipient(s) only. Views or opinions, if any,
presented in 
this email are solely those of the author and may not
necessarily reflect 
the views or opinions of SSN Institutions (SSN) or its
affiliates. Any form 
of reproduction, dissemination, copying, disclosure,
modification, 
distribution and / or publication of this message without the
prior written 
consent of authorized representative of SSN is strictly
prohibited. If you 
have received this email in error please delete it and
notify the sender 
immediately.
---------------------------------------------------------------------
Header of this mail should have a valid DKIM signature for the domain 
ssn.edu.in <http://www.ssn.edu.in/>