Fix memory leak.
This commit is contained in:
parent
7270c1771f
commit
409acceffa
2 changed files with 14 additions and 5 deletions
|
@ -15,7 +15,7 @@ obj = ${src:.c=.o}
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
||||||
CFLAGS = -O3 -march=native -pipe -flto=thin -Wall -Wextra -Wno-unused-parameter
|
CFLAGS = -O3 -march=native -pipe -flto -Wall -Wextra -Wno-unused-parameter
|
||||||
LDFLAGS = -Wl,-O3 -lcrypto -liconv -lz -ljbig -ljpeg -Wl,--as-needed
|
LDFLAGS = -Wl,-O3 -lcrypto -liconv -lz -ljbig -ljpeg -Wl,--as-needed
|
||||||
|
|
||||||
CFLAGS += -I/usr/local/include
|
CFLAGS += -I/usr/local/include
|
||||||
|
|
17
src/cnki.c
17
src/cnki.c
|
@ -44,10 +44,19 @@ cnki_destroy(cnki_t **param)
|
||||||
if (*param != NULL) {
|
if (*param != NULL) {
|
||||||
if ((*param)->file_stat != NULL)
|
if ((*param)->file_stat != NULL)
|
||||||
free((*param)->file_stat);
|
free((*param)->file_stat);
|
||||||
if ((*param)->object_outline != NULL)
|
|
||||||
free((*param)->object_outline);
|
object_outline_t *ptr_outline;
|
||||||
if ((*param)->object_hn != NULL)
|
while ((ptr_outline = (*param)->object_outline) != NULL) {
|
||||||
free((*param)->object_hn);
|
(*param)->object_outline = (*param)->object_outline->next;
|
||||||
|
free(ptr_outline);
|
||||||
|
}
|
||||||
|
|
||||||
|
object_hn_t *ptr_hn;
|
||||||
|
while ((ptr_hn = (*param)->object_hn) != NULL) {
|
||||||
|
(*param)->object_hn = (*param)->object_hn->next;
|
||||||
|
free(ptr_hn);
|
||||||
|
}
|
||||||
|
|
||||||
free(*param);
|
free(*param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue