scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit a8c0229b8ae756c5fee352cd4490c788d87b30d5
parent e42a0145f6bd89a95cc420f703f42cfb7bcd25bd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Jan 2020 15:47:30 +0100

libmach: Rework of newmap()

Small whitespaces and variable reduction.

Diffstat:
Msrc/libmach/newmap.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/libmach/newmap.c b/src/libmach/newmap.c @@ -11,19 +11,18 @@ Map * newmap(int n, FILE *fp) { - size_t siz, vsiz; + size_t vsiz; struct mapsec *p; Map *map; - siz = sizeof(*map); if (n > SIZE_MAX/sizeof(struct mapsec)) goto out_range; - vsiz = n * sizeof(struct mapsec); - if (vsiz > SIZE_MAX - siz) + if (vsiz > SIZE_MAX - sizeof(*map)) goto out_range; + vsiz += sizeof(*map); - if ((map = malloc(siz + vsiz)) == NULL) + if ((map = malloc(vsiz)) == NULL) return NULL; map->n = n; @@ -34,6 +33,6 @@ newmap(int n, FILE *fp) return map; out_range: - errno = ERANGE; - return NULL; + errno = ERANGE; + return NULL; }