diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-23 10:51:51 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-23 17:10:58 -0300 |
| commit | 7b743fcc7d568f13512a59089c5214bb6fa3282f (patch) | |
| tree | ab133f70ded7b9b415115345adfc6ff043117b03 /src/pdf_bridge.c | |
| parent | b8f076b63d6fcbb01539d5541520a32bccc0e219 (diff) | |
| download | pardes-7b743fcc7d568f13512a59089c5214bb6fa3282f.tar.gz pardes-7b743fcc7d568f13512a59089c5214bb6fa3282f.zip | |
Audit (LSP, PDF): one client dispatch, docParams, renameEdits in one loop, std.c externs; one whole-page render, openBytes only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pdf_bridge.c')
| -rw-r--r-- | src/pdf_bridge.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/pdf_bridge.c b/src/pdf_bridge.c index 594db0f9..b1537107 100644 --- a/src/pdf_bridge.c +++ b/src/pdf_bridge.c @@ -321,8 +321,8 @@ pardes_pdf_grown_capacity(size_t current, size_t needed, size_t maximum) return capacity; } -static pardes_pdf_document * -pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t length, int *page_count) +pardes_pdf_document * +pardes_pdf_open_memory(const unsigned char *bytes, size_t length, int *page_count) { pardes_pdf_document *state; fz_context *ctx; @@ -331,7 +331,7 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng fz_stream *stream = NULL; int pages = 0; - if ((path == NULL && bytes == NULL) || page_count == NULL) + if (bytes == NULL || page_count == NULL) return NULL; state = pardes_pdf_allocate_document(); @@ -356,13 +356,9 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng fz_try(ctx) { fz_register_document_handlers(ctx); - if (path != NULL) { - doc = fz_open_document(ctx, path); - } else { - buffer = fz_new_buffer_from_copied_data(ctx, bytes, length); - stream = fz_open_buffer(ctx, buffer); - doc = fz_open_document_with_stream(ctx, "application/pdf", stream); - } + buffer = fz_new_buffer_from_copied_data(ctx, bytes, length); + stream = fz_open_buffer(ctx, buffer); + doc = fz_open_document_with_stream(ctx, "application/pdf", stream); pages = fz_count_pages(ctx, doc); if (pages < 1) fz_throw(ctx, FZ_ERROR_FORMAT, "PDF has no pages"); @@ -389,18 +385,6 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng return state; } -pardes_pdf_document * -pardes_pdf_open(const char *path, int *page_count) -{ - return pardes_pdf_open_source(path, NULL, 0, page_count); -} - -pardes_pdf_document * -pardes_pdf_open_memory(const unsigned char *bytes, size_t length, int *page_count) -{ - return pardes_pdf_open_source(NULL, bytes, length, page_count); -} - void pardes_pdf_close(pardes_pdf_document *document) { |
