aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdf_cnki.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf_cnki.c')
-rw-r--r--src/pdf_cnki.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/pdf_cnki.c b/src/pdf_cnki.c
index 84274b8..a1c7a09 100644
--- a/src/pdf_cnki.c
+++ b/src/pdf_cnki.c
@@ -106,6 +106,26 @@ _outline(pdf_object_t **pdf, object_outline_tree_t **outline_tree, int id, int *
return 0;
}
+static int
+_outline_free(object_outline_tree_t **outline_tree)
+{
+ object_outline_tree_t *ptr = *outline_tree;
+ for (;;) {
+ if (ptr->right != NULL)
+ _outline_free(&ptr->right);
+
+ if (ptr->left != NULL) {
+ ptr = ptr->left;
+ free(ptr->up);
+ } else {
+ free(ptr);
+ break;
+ }
+ }
+
+ return 0;
+}
+
int
pdf_cnki_outline(pdf_object_t **pdf, object_outline_t **outline, int **ids)
{
@@ -119,8 +139,7 @@ pdf_cnki_outline(pdf_object_t **pdf, object_outline_t **outline, int **ids)
int *ret;
_outline(pdf, &outline_tree->left, outline_tree->id, &ret);
-
- free(outline_tree);
+ _outline_free(&outline_tree);
snprintf(buf, 128,
"<<\n/Type Outlines\n/First %d 0 R\n/Last %d 0 R\n/Count %d\n>>",