Skip to content

Commit 8cc7a25

Browse files
author
sjw
committed
Add hd_drop_page
1 parent aeb55f3 commit 8cc7a25

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

include/hdtd/document.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,9 @@ hd_page *hd_load_page(hd_context *ctx, hd_document *doc, int number);
169169

170170
void hd_run_page_contents(hd_context *ctx, hd_page *page, char* buf, uint32_t *extract_len);
171171

172+
/*
173+
hd_drop_page: Free a loaded page.
174+
*/
175+
void hd_drop_page(hd_context *ctx, hd_page *page);
176+
172177
#endif //HDCONTENTS_HDTD_DOCUMENT_H

source/hdtd/document.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,16 @@ hd_run_page_contents(hd_context *ctx, hd_page *page, char* buf, uint32_t *extrac
151151
hd_rethrow(ctx);
152152
}
153153
}
154+
}
155+
156+
157+
void
158+
hd_drop_page(hd_context *ctx, hd_page *page)
159+
{
160+
if (hd_drop_imp(ctx, page, &page->refs))
161+
{
162+
if (page->drop_page)
163+
page->drop_page(ctx, page);
164+
hd_free(ctx, page);
165+
}
154166
}

source/hdtd/stream-open.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ hd_drop_stream(hd_context *ctx, hd_stream *stm)
88
{
99
if (hd_drop_imp(ctx, stm, &stm->refs))
1010
{
11+
//printf("hd_drop_stream is run\n");
1112
if (stm->close)
1213
stm->close(ctx, stm->state);
1314
hd_free(ctx, stm);

source/pdf/pdf-page.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pdf_load_page(hd_context *ctx, pdf_document *doc, int number)
221221
hd_rethrow(ctx);
222222

223223
page = pdf_new_page(ctx, doc);
224-
page->obj = pdf_keep_obj(ctx, pageobj);
224+
page->obj = pageobj;//pdf_keep_obj(ctx, pageobj);
225225
return page;
226226

227227
}

0 commit comments

Comments
 (0)