summaryrefslogtreecommitdiff
path: root/fitz/stm_buffer.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-09-14 17:36:57 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-09-15 14:50:17 +0100
commitb51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch)
tree1ab685ccd356e7fdc832b2e3322c0486b2670cfb /fitz/stm_buffer.c
parent89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff)
downloadmupdf-b51ef0eea028c73b6379e832eaa34fff3fbbb927.tar.xz
Add context to mupdf.
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
Diffstat (limited to 'fitz/stm_buffer.c')
-rw-r--r--fitz/stm_buffer.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c
index 4c7410c3..edd5c9c9 100644
--- a/fitz/stm_buffer.c
+++ b/fitz/stm_buffer.c
@@ -1,15 +1,15 @@
#include "fitz.h"
fz_buffer *
-fz_new_buffer(int size)
+fz_new_buffer(fz_context *ctx, int size)
{
fz_buffer *b;
size = size > 1 ? size : 16;
- b = fz_malloc(sizeof(fz_buffer));
+ b = fz_malloc(ctx, sizeof(fz_buffer));
b->refs = 1;
- b->data = fz_malloc(size);
+ b->data = fz_malloc(ctx, size);
b->cap = size;
b->len = 0;
@@ -24,26 +24,26 @@ fz_keep_buffer(fz_buffer *buf)
}
void
-fz_drop_buffer(fz_buffer *buf)
+fz_drop_buffer(fz_context *ctx, fz_buffer *buf)
{
if (--buf->refs == 0)
{
- fz_free(buf->data);
- fz_free(buf);
+ fz_free(ctx, buf->data);
+ fz_free(ctx, buf);
}
}
void
-fz_resize_buffer(fz_buffer *buf, int size)
+fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size)
{
- buf->data = fz_realloc(buf->data, size, 1);
+ buf->data = fz_realloc(ctx, buf->data, size);
buf->cap = size;
if (buf->len > buf->cap)
buf->len = buf->cap;
}
void
-fz_grow_buffer(fz_buffer *buf)
+fz_grow_buffer(fz_context *ctx, fz_buffer *buf)
{
- fz_resize_buffer(buf, (buf->cap * 3) / 2);
+ fz_resize_buffer(ctx, buf, (buf->cap * 3) / 2);
}