Thread (8 messages) 8 messages, 2 authors, 2015-01-21

[PATCH 4/4] util: remove dead code in freadline_wrapped

flat view
STALE4277d

From: Caio Marcelo de Oliveira Filho <hidden>
Date: 2015-01-21 11:37:49
Subsystem: the rest · Maintainer: Linus Torvalds

Each loop iteration starts with 'i < size'. When i is changed
the invariant is kept by checking if 'i == size' and growing the
buffer.
---
 shared/util.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/shared/util.c b/shared/util.c
index 479f0fe..1a2b17c 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -314,13 +314,7 @@ char *freadline_wrapped(FILE *fp, unsigned int *linenum)
 			n++;
 
 			{
-				char *ret;
-				if (i == size) {
-					ret = realloc(buf, size + 1);
-					if (!ret)
-						return NULL;
-				} else
-					ret = buf;
+				char *ret = buf;
 				ret[i] = '\0';
 				buf = NULL;
 				if (linenum)
-- 
2.2.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help