HPDF_FreeDoc (HPDF_Doc pdf) { HPDF_PTRACE ((" HPDF_FreeDoc\n")); if (HPDF_Doc_Validate (pdf)) { if (pdf->xref) { HPDF_Xref_Free (pdf->xref); pdf->xref = NULL; } if (pdf->font_mgr) { HPDF_List_Free (pdf->font_mgr); pdf->font_mgr = NULL; } if (pdf->fontdef_list) CleanupFontDefList (pdf); HPDF_MemSet(pdf->ttfont_tag, 0, 6); pdf->pdf_version = HPDF_VER_13; pdf->outlines = NULL; pdf->catalog = NULL; pdf->root_pages = NULL; pdf->cur_pages = NULL; pdf->cur_page = NULL; pdf->encrypt_on = HPDF_FALSE; pdf->cur_page_num = 0; pdf->cur_encoder = NULL; pdf->def_encoder = NULL; pdf->page_per_pages = 0; if (pdf->page_list) { HPDF_List_Free (pdf->page_list); pdf->page_list = NULL; } pdf->encrypt_dict = NULL; pdf->info = NULL; HPDF_Error_Reset (&pdf->error); if (pdf->stream) { HPDF_Stream_Free (pdf->stream); pdf->stream = NULL; } } }
void HPDF_Xref_Free (HPDF_Xref xref) { HPDF_UINT i; HPDF_XrefEntry entry; HPDF_Xref tmp_xref; HPDF_PTRACE((" HPDF_Xref_Free\n")); /* delete xref entries. where prev element is not NULL, * delete all xref entries recursively. */ while (xref) { /* delete all objects belong to the xref. */ if (xref->entries) { for (i = 0; i < xref->entries->count; i++) { entry = HPDF_Xref_GetEntry (xref, i); if (entry->obj) HPDF_Obj_ForceFree (xref->mmgr, entry->obj); HPDF_FreeMem (xref->mmgr, entry); } HPDF_List_Free(xref->entries); } if (xref->trailer) HPDF_Dict_Free (xref->trailer); tmp_xref = xref->prev; HPDF_FreeMem (xref->mmgr, xref); xref = tmp_xref; } }
void HPDF_Array_Free (HPDF_Array array) { if (!array) return; HPDF_PTRACE((" HPDF_Array_Free\n")); HPDF_Array_Clear (array); HPDF_List_Free (array->list); array->header.obj_class = 0; HPDF_FreeMem (array->mmgr, array); }
static void FreeFontDefList (HPDF_Doc pdf) { HPDF_List list = pdf->fontdef_list; HPDF_UINT i; HPDF_PTRACE ((" HPDF_Doc_FreeFontDefList\n")); for (i = 0; i < list->count; i++) { HPDF_FontDef def = (HPDF_FontDef)HPDF_List_ItemAt (list, i); HPDF_FontDef_Free (def); } HPDF_List_Free (list); pdf->fontdef_list = NULL; }
static void FreeEncoderList (HPDF_Doc pdf) { HPDF_List list = pdf->encoder_list; HPDF_UINT i; HPDF_PTRACE ((" FreeEncoderList\n")); for (i = 0; i < list->count; i++) { HPDF_Encoder encoder = (HPDF_Encoder)HPDF_List_ItemAt (list, i); HPDF_Encoder_Free (encoder); } HPDF_List_Free (list); pdf->encoder_list = NULL; }
void HPDF_CIDFontDef_FreeWidth (HPDF_FontDef fontdef) { HPDF_CIDFontDefAttr attr = (HPDF_CIDFontDefAttr)fontdef->attr; HPDF_UINT i; HPDF_PTRACE (" HPDF_FontDef_Validate\n"); for (i = 0; i < attr->widths->count; i++) { HPDF_CID_Width *w = (HPDF_CID_Width *)HPDF_List_ItemAt (attr->widths, i); HPDF_FreeMem (fontdef->mmgr, w); } HPDF_List_Free (attr->widths); attr->widths = NULL; fontdef->valid = HPDF_FALSE; }