LoadMemDocument Pointer Lifetime

42 views
Skip to first unread message

Justin Pierce

unread,
May 10, 2023, 3:25:46 AM5/10/23
to pdfium
Hello all,

The comments for `FPDF_LoadMemDocument` and `FPDF_LoadMemDocument64` state the following:

The memory buffer must remain valid when the document is open.


Is this comment accurate? My understanding is that I am expected to not delete the pointer passed to the first parameter of the aforementioned functions.

Suppose the above is accurate, is there a reason why this is necessary, whereas ` FPDF_LoadDocument` and ` FPDF_CreateNewDocument` are able to manage memory on their own? I am just looking to trim down memory usage where possible.

Cheers,
JD

K. Moon

unread,
May 10, 2023, 12:48:31 PM5/10/23
to Justin Pierce, pdfium
Yes, this is accurate. The document may be loaded lazily.

--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/bc36747f-7c9b-46ba-8041-c0ab724a7aa9n%40googlegroups.com.

geisserml

unread,
May 10, 2023, 4:48:33 PM5/10/23
to pdfium
Yes, this is an absolutely binding requirement, and violating it would lead to corrupted results and/or a segfault. I've already had my experiences with that.

Justin Pierce

unread,
May 10, 2023, 9:37:26 PM5/10/23
to pdfium
Just wanted to confirm - thanks as always
Reply all
Reply to author
Forward
0 new messages