summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-10-12 14:45:23 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-10-12 14:45:42 +0200
commit69c379990d83d83682b23eac3ddf390c0d85e976 (patch)
treec6d2fd66d472784924e524c95552aa41d6c87ce6 /source/fitz
parentcf94c2a1e8cac52074183b31f75b71480dbdcea1 (diff)
downloadmupdf-69c379990d83d83682b23eac3ddf390c0d85e976.tar.xz
Use pool allocator when parsing CSS.
Fixes memory leaks when parsing throws exceptions and saves a lot of tiny mallocs for objects that have common life times.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/pool.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/fitz/pool.c b/source/fitz/pool.c
index e676947f..2591c563 100644
--- a/source/fitz/pool.c
+++ b/source/fitz/pool.c
@@ -31,6 +31,14 @@ void *fz_pool_alloc(fz_context *ctx, fz_pool *pool, size_t size)
return ptr;
}
+char *fz_pool_strdup(fz_context *ctx, fz_pool *pool, const char *s)
+{
+ size_t n = strlen(s) + 1;
+ char *p = fz_pool_alloc(ctx, pool, n);
+ memcpy(p, s, n);
+ return p;
+}
+
void fz_drop_pool(fz_context *ctx, fz_pool *pool)
{
fz_pool_node *node = pool->head;