Exemplo n.º 1
0
void
pdc_fclose(pdc_file *sfp)
{
    if (sfp)
    {
        if (sfp->fp)
        {
            pdc_fclose_logg(sfp->pdc, sfp->fp);
            sfp->fp = NULL;
        }
        else if (sfp->wrmode)
        {
            if (sfp->data)
            {
                pdc_free(sfp->pdc, sfp->data);
                sfp->data = NULL;
            }
        }

        if (sfp->filename)
        {
            pdc_free(sfp->pdc, sfp->filename);
            sfp->filename = NULL;
        }

        pdc_free(sfp->pdc, sfp);
    }
}
Exemplo n.º 2
0
static void
pdc_close_stream(pdc_output *out)
{
    /* this time we MUST flush the stream -
    ** even if (flush == pdc_flush_none)
    */
    out->flush = pdc_flush_heavy;
    pdc_flush_stream(out);

#ifdef HAVE_LIBZ
    /*
     * This is delicate: we must ignore the return value because of the
     * following reasoning: We are called in two situations:
     * - end of document
     * - exception
     * In the first case compression is inactive, so deflateEnd() will
     * fail only in the second case. However, when an exception occurs
     * the document is definitely unusable, so we avoid recursive exceptions
     * or an (unallowed) exception in PDF_delete().
     */

    (void) deflateEnd(&out->z);
#endif

    /* close the output file if writing to file, but do not close the
     * in-core output stream since the caller will have to
     * fetch the buffer after PDF_close().
     */
    if (out->fp)
    {
        pdc_fclose_logg(out->pdc, out->fp);

	/* mark fp as dead in case the error handler jumps in later */
	out->fp = NULL;
    }
}