From 69c379990d83d83682b23eac3ddf390c0d85e976 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 12 Oct 2016 14:45:23 +0200 Subject: 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. --- source/fitz/pool.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/fitz') 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; -- cgit v1.2.3