PDFLIB_API void PDFLIB_CALL PDF_close(PDF *p) { static const char fn[] = "PDF_close"; PDF_TRACE(("%s\t\t(pdf[%p]);\n", fn, (void *) p)); if (PDF_SANITY_CHECK_FAILED(p)) return; PDF_CHECK_SCOPE(p, fn, pdf_state_document); if (PDF_GET_STATE(p) != pdf_state_error) { if (p->current_page == 0) pdf_error(p, PDF_RuntimeError, "Empty document"); pdf_wrapup_document(p); /* dump the remaining PDF structures */ } pdf_flush_stream(p); pdf_cleanup_document(p); /* UPR stuff not released here but in PDF_delete() */ PDF_SET_STATE(p, fn, pdf_state_object); }
void pdf__delete(PDF *p) { /* * Close the output stream, because it could be open */ pdc_close_output(p->out); /* * Clean up page-related stuff if necessary. Do not raise * an error here since we may be called from the error handler. */ pdf_cleanup_document(p); pdf_cleanup_stringlists(p); pdf_cleanup_font_curroptions(p); pdc_cleanup_output(p->out, pdc_false); if (p->out) pdc_free(p->pdc, p->out); /* we never reach this point if (p->pdc == NULL). */ pdc_delete_core(p->pdc); /* free the PDF structure and try to protect against duplicated calls */ p->magic = 0L; /* we don't reach this with the wrong magic */ (*p->freeproc)(p, (void *) p); }
PDFLIB_API void PDFLIB_CALL PDF_delete(PDF *p) { static const char fn[] = "PDF_delete"; PDF_TRACE(("%s\t(pdf[%p]);\n", fn, (void *) p)); if (PDF_SANITY_CHECK_FAILED(p)) return; if (p->errorhandler == NULL) return; /* nothing to do with dummy PDF struct (see PDF_new2()) */ PDF_CHECK_SCOPE(p, fn, pdf_state_object); /* check whether the caller forgot to fetch the last chunk of data */ if (PDF_GET_STATE(p) != pdf_state_error && pdf_buffer_not_empty(p)) { pdf_error(p, PDF_RuntimeError, "Must call PDF_get_buffer() after PDF_close()"); } /* * Clean up page-related stuff if necessary. Do not raise * an error here since we may be called from the error handler. */ if (PDF_GET_STATE(p) != pdf_state_object) { pdf_cleanup_document(p); } /* close the output stream. * This can't be done in PDF_close() because the caller may fetch * the buffer only after PDF_close()ing the document. */ pdf_close_stream(p); pdf_cleanup_resources(p); /* release the resources tree */ #ifdef HAVE_PDI pdf_cleanup_pdi(p); #endif if (p->binding) p->free(p, p->binding); if (p->prefix) p->free(p, p->prefix); /* free the PDF structure and try to protect against duplicated calls */ p->magic = 0L; /* we don't reach this with the wrong magic */ p->free(p, (void *)p); }