diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-03-12 11:19:09 -0500 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-03-22 12:07:26 +0100 |
commit | cfb66cd25bbf31857b471735e5ff0f7c2aea4d3c (patch) | |
tree | 8d8d06c9e2c880611a3c8cc025d8c35fe38d59ba /include/mupdf/fitz/buffer.h | |
parent | 3832d0c7ab87aa1f2b3a3dbebe43a37e4055d121 (diff) | |
download | mupdf-cfb66cd25bbf31857b471735e5ff0f7c2aea4d3c.tar.xz |
Rename fz_putc/puts/printf to fz_write_*.
Rename fz_write to fz_write_data.
Rename fz_write_buffer_* and fz_buffer_printf to fz_append_*.
Be consistent in naming:
fz_write_* calls write to fz_output.
fz_append_* calls append to fz_buffer.
Update documentation.
Diffstat (limited to 'include/mupdf/fitz/buffer.h')
-rw-r--r-- | include/mupdf/fitz/buffer.h | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/include/mupdf/fitz/buffer.h b/include/mupdf/fitz/buffer.h index df3f216a..96fcc185 100644 --- a/include/mupdf/fitz/buffer.h +++ b/include/mupdf/fitz/buffer.h @@ -15,34 +15,27 @@ typedef struct fz_buffer_s fz_buffer; /* fz_keep_buffer: Increment the reference count for a buffer. - buf: The buffer to increment the reference count for. - - Returns a pointer to the buffer. Does not throw exceptions. + Returns a pointer to the buffer. */ fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf); /* fz_drop_buffer: Decrement the reference count for a buffer. - - buf: The buffer to decrement the reference count for. */ void fz_drop_buffer(fz_context *ctx, fz_buffer *buf); /* - fz_buffer_storage: Retrieve information on the storage currently used - by a buffer. + fz_buffer_storage: Retrieve internal memory of buffer. - data: Pointer to place to retrieve data pointer. + datap: Output parameter that will be pointed to the data. - Returns length of stream. + Returns the current size of the data in bytes. */ -size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **data); +size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap); /* fz_string_from_buffer: Ensure that a buffer's 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); @@ -51,8 +44,7 @@ const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf); capacity: Initial capacity. - Returns pointer to new buffer. Throws exception on allocation - failure. + Returns pointer to new buffer. */ fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity); @@ -85,60 +77,47 @@ fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t s fz_resize_buffer: Ensure that a buffer has a given capacity, truncating data if required. - buf: The buffer to alter. - capacity: The desired capacity for the buffer. If the current size of the buffer contents is smaller than capacity, it is truncated. - */ void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity); /* fz_grow_buffer: Make some space within a buffer (i.e. ensure that capacity > size). - - buf: The buffer to grow. - - May throw exception on failure to allocate. */ void fz_grow_buffer(fz_context *ctx, fz_buffer *buf); /* - fz_trim_buffer: Trim wasted capacity from a buffer. - - buf: The buffer to trim. + fz_trim_buffer: Trim wasted capacity from a buffer by resizing internal memory. */ void fz_trim_buffer(fz_context *ctx, fz_buffer *buf); /* - fz_append_buffer: Concatenate buffers - - buf: first to concatenate and the holder of the result - extra: second to concatenate - - May throw exception on failure to allocate. + fz_append_buffer: Append the contents of source buffer to destination buffer. */ -void fz_append_buffer(fz_context *ctx, fz_buffer *buf, fz_buffer *extra); +void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source); /* - fz_write_buffer*: write to a buffer. - fz_buffer_printf: print formatted to a buffer. - fz_buffer_print_pdfstring: Print a string using PDF syntax and escapes. - The buffer will grow as required. + fz_append_*: Append data to a buffer. + fz_append_printf: Format and append data to buffer using printf-like formatting (see fz_vsnprintf). + fz_append_pdf_string: Append a string with PDF syntax quotes and escapes. + The buffer will automatically grow as required. */ -void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t len); -void fz_write_buffer_byte(fz_context *ctx, fz_buffer *buf, int val); -void fz_write_buffer_rune(fz_context *ctx, fz_buffer *buf, int val); -void fz_write_buffer_int32_le(fz_context *ctx, fz_buffer *buf, int x); -void fz_write_buffer_int16_le(fz_context *ctx, fz_buffer *buf, int x); -void fz_write_buffer_bits(fz_context *ctx, fz_buffer *buf, int val, int bits); -void fz_write_buffer_pad(fz_context *ctx, fz_buffer *buf); -size_t fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...); -size_t fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args); -void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text); +void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len); +void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data); +void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c); +void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c); +void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x); +void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x); +void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count); +void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf); +size_t fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...); +size_t fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args); +void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text); /* - fz_terminate_buffer: zero-terminate buffer in order to use as a C string. + fz_terminate_buffer: Zero-terminate buffer in order to use as a C string. This byte is invisible and does not affect the length of the buffer as returned by fz_buffer_storage. The zero byte is written *after* the data, and subsequent writes will overwrite the terminating byte. @@ -146,7 +125,7 @@ void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char * void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf); /* - fz_md5_buffer: create MD5 digest of buffer contents. + fz_md5_buffer: Create MD5 digest of buffer contents. */ void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]); |