From 7b743fcc7d568f13512a59089c5214bb6fa3282f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 23 Oct 2026 10:51:51 -0300 Subject: 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 --- src/pdf_bridge.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/pdf_bridge.c') 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) { -- cgit v1.3