libds

a collection of simple data structures
Log | Files | Refs | LICENSE

commit 321aa046d5eb8d5e44eacfd268f8eef4269a7851
parent 0992e65b3a25d6b0f16a4615528dc0d34f8a46b5
Author: sin <sin@2f30.org>
Date:   Tue,  8 Apr 2014 10:11:59 +0100

Fix infinite loop

Diffstat:
Mconfig.mk | 2+-
Mvector.c | 3+--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/config.mk b/config.mk @@ -13,7 +13,7 @@ LIBS = -L/usr/lib -lc # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} # compiler and linker diff --git a/vector.c b/vector.c @@ -1,5 +1,4 @@ /* Vector implementation using a hashed-array tree */ -#include <stdio.h> #include <stdlib.h> struct leaf { @@ -24,7 +23,7 @@ grow(struct vector *v) for (i = 0; i < v->sz / 2; i++) { tmp[i] = calloc(v->sz * 2, sizeof(**tmp)); if (!tmp[i]) { - while (--i >= 0) + while (i-- > 0) free(tmp[i]); free(tmp); return -1;