[PATCH 1/2] getdelim: tiny shrinkage
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Thu Oct 6 13:40:52 UTC 2011
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
libc/stdio/getdelim.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c
index 987e32a..c264b32 100644
--- a/libc/stdio/getdelim.c
+++ b/libc/stdio/getdelim.c
@@ -30,7 +30,7 @@ ssize_t getdelim(char **__restrict lineptr, size_t *__restrict n,
{
register char *buf;
ssize_t pos = -1;
- int c;
+ int ch;
__STDIO_AUTO_THREADLOCK_VAR;
if (!lineptr || !n || !stream) { /* Be compatable with glibc... even */
@@ -49,18 +49,17 @@ ssize_t getdelim(char **__restrict lineptr, size_t *__restrict n,
pos = 1;
do {
- if (pos >= *n) {
- if (!(buf = realloc(buf, *n + GETDELIM_GROWBY))) {
+ if ((size_t)pos >= *n) {
+ if (!(buf = realloc(buf, *n += GETDELIM_GROWBY))) {
pos = -1;
break;
}
- *n += GETDELIM_GROWBY;
*lineptr = buf;
}
- if ((c = __GETC_UNLOCKED(stream)) != EOF) {
- buf[++pos - 2] = c;
- if (c != delimiter) {
+ if ((ch = __GETC_UNLOCKED(stream)) != EOF) {
+ buf[++pos - 2] = ch;
+ if (ch != delimiter) {
continue;
}
}
--
1.7.6.3
More information about the uClibc
mailing list