libc/stdlib: Minor improvements to realloc() - scc - simple c99 compiler
HTML git clone git://git.simple-cc.org/scc
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 84128eaf37e33fed023f271018b157b7398ad91c
DIR parent ae0058502d81d2742783b1d1800784319341ff12
HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Sun, 4 Jan 2026 21:18:49 +0100
libc/stdlib: Minor improvements to realloc()
Diffstat:
M src/libc/stdlib/realloc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
DIR diff --git a/src/libc/stdlib/realloc.c b/src/libc/stdlib/realloc.c
@@ -15,9 +15,7 @@ realloc(void *ptr, size_t nbytes)
if (nbytes == 0) {
free(ptr);
ptr = NULL;
- }
-
- if (nbytes > SIZE_MAX - sizeof(Header)-1) {
+ } else if (nbytes > SIZE_MAX - sizeof(Header)-1) {
errno = ENOMEM;
return NULL;
}