[PR #288] [MERGED] Add image buffers without a temporary file #456

Closed
opened 2026-05-05 12:16:23 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jmcnamara/libxlsxwriter/pull/288
Author: @evanmiller
Created: 5/6/2020
Status: Merged
Merged: 5/8/2020
Merged by: @jmcnamara

Base: masterHead: in-memory-images


📝 Commits (1)

  • 2f87dc1 Add image buffers without a temporary file

📊 Changes

4 files changed (+21 additions, -2 deletions)

View changed files

📝 .travis.yml (+1 -0)
📝 CMakeLists.txt (+4 -0)
📝 src/Makefile (+5 -0)
📝 src/worksheet.c (+11 -2)

📄 Description

Use fmemopen to create an in-memory FILE * for reading in image attributes. This avoids creating a separate temporary file for every image added to the worksheet.

Passing NULL as the first argument creates a buffer managed by fmemopen; I tried it the other way (passing in the buffer created elsewhere in worksheet_insert_image_buffer_opt) but it didn't seem to work. (Possibly a case of me misusing the API.)

According to the documentation, fclose will free the buffer, so I believe that this one line change is sufficient.

According to header comments on my platform (macOS 10.15) it looks like fmemopen is defined by POSIX.1-2008. We might need to wrap the feature in a #define to support older platforms. The change compiles, runs, and seems to work on macOS, but I haven't tested other platforms.

See #287 and https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jmcnamara/libxlsxwriter/pull/288 **Author:** [@evanmiller](https://github.com/evanmiller) **Created:** 5/6/2020 **Status:** ✅ Merged **Merged:** 5/8/2020 **Merged by:** [@jmcnamara](https://github.com/jmcnamara) **Base:** `master` ← **Head:** `in-memory-images` --- ### 📝 Commits (1) - [`2f87dc1`](https://github.com/jmcnamara/libxlsxwriter/commit/2f87dc129092baad7ec91b255671ba91a273192e) Add image buffers without a temporary file ### 📊 Changes **4 files changed** (+21 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `.travis.yml` (+1 -0) 📝 `CMakeLists.txt` (+4 -0) 📝 `src/Makefile` (+5 -0) 📝 `src/worksheet.c` (+11 -2) </details> ### 📄 Description Use `fmemopen` to create an in-memory `FILE *` for reading in image attributes. This avoids creating a separate temporary file for every image added to the worksheet. Passing `NULL` as the first argument creates a buffer managed by `fmemopen`; I tried it the other way (passing in the buffer created elsewhere in `worksheet_insert_image_buffer_opt`) but it didn't seem to work. (Possibly a case of me misusing the API.) According to the documentation, `fclose` will free the buffer, so I believe that this one line change is sufficient. According to header comments on my platform (macOS 10.15) it looks like `fmemopen` is defined by POSIX.1-2008. We might need to wrap the feature in a #define to support older platforms. The change compiles, runs, and seems to work on macOS, but I haven't tested other platforms. See #287 and https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 12:16:23 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#456
No description provided.