summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-11 16:05:30 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-14 16:09:39 +0000
commit37f95f87bdfb2e0b01d649afae5fffe60bf99d3a (patch)
treeda3491c62d6af86c1a5bc4e523e8f9ebe19793d1 /include
parentc0e1dfdab1a13def046e94d771f8a821ba2a10d9 (diff)
downloadmupdf-37f95f87bdfb2e0b01d649afae5fffe60bf99d3a.tar.xz
Make fz_buffer structure private to fitz.
Move the definition of the structure contents into new fitz-imp.h file. Make all code outside of fitz access the buffer through the defined API. Add a convenience API for people that want to get buffers as null terminated C strings.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/buffer.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/include/mupdf/fitz/buffer.h b/include/mupdf/fitz/buffer.h
index 40e46e73..70214b21 100644
--- a/include/mupdf/fitz/buffer.h
+++ b/include/mupdf/fitz/buffer.h
@@ -38,14 +38,13 @@ void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
*/
size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **data);
-struct fz_buffer_s
-{
- int refs;
- unsigned char *data;
- size_t cap, len;
- int unused_bits;
- int shared;
-};
+/*
+ fz_string_from_buffer: Ensure that a buffers data ends in a
+ 0 byte, and return a pointer to it.
+
+ Returns pointer to data.
+*/
+const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
/*
fz_new_buffer: Create a new buffer.
@@ -143,4 +142,20 @@ void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *
*/
void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
+/*
+ fz_buffer_extract: Take ownership of buffer contents.
+ Performs the same task as fz_buffer_storage, but ownership of
+ the data buffer returns with this call. The buffer is left
+ empty.
+
+ Note: Bad things may happen if this is called on a buffer with
+ multiple references that is being used from multiple threads.
+
+ data: Pointer to place to retrieve data pointer.
+
+ Returns length of stream.
+*/
+size_t fz_buffer_extract(fz_context *ctx, fz_buffer *buf, unsigned char **data);
+
+
#endif