diff options
author | yzrh <yzrh@noema.org> | 2021-01-27 16:42:52 +0000 |
---|---|---|
committer | yzrh <yzrh@noema.org> | 2021-01-29 21:50:20 +0000 |
commit | 409acceffa5698853dc63f143df960849be8dc32 (patch) | |
tree | e063e0f9c05e0de3f47102880db06c6acf362aad /src | |
parent | 7270c1771f2ae68d681109be0c6a62bedd5cc009 (diff) | |
download | melon-409acceffa5698853dc63f143df960849be8dc32.tar.gz melon-409acceffa5698853dc63f143df960849be8dc32.tar.zst |
Fix memory leak.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/cnki.c | 17 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile index 005f6da..ec98cf7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 @@ -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); } } |