Fix memory leak.

This commit is contained in:
yzrh 2021-01-27 16:42:52 +00:00
parent 7270c1771f
commit 409acceffa
2 changed files with 14 additions and 5 deletions

View file

@ -15,7 +15,7 @@ obj = ${src:.c=.o}
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
CFLAGS += -I/usr/local/include

View file

@ -44,10 +44,19 @@ cnki_destroy(cnki_t **param)
if (*param != NULL) {
if ((*param)->file_stat != NULL)
free((*param)->file_stat);
if ((*param)->object_outline != NULL)
free((*param)->object_outline);
if ((*param)->object_hn != NULL)
free((*param)->object_hn);
object_outline_t *ptr_outline;
while ((ptr_outline = (*param)->object_outline) != NULL) {
(*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);
}
}