From 1498c9c333d7579231ac44a91f00f0a49360702d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 12 Jun 2009 07:38:00 +0100 Subject: [PATCH] [script] Also mmap backing storage for the pattern descriptions These can be reasonably large and persist for long times due to the font holdover caches, so manually swap them out to save space on tiny swapless machines. --- util/cairo-script/cairo-script-operators.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index 452243c05..44f976462 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -1709,10 +1709,22 @@ _ft_create_for_pattern (csi_t *ctx, ctx->_faces = _csi_list_prepend (ctx->_faces, &data->blob.list); data->ctx = cairo_script_interpreter_reference (ctx); data->blob.hash = tmpl.hash; - data->blob.bytes = tmpl.bytes; data->blob.len = tmpl.len; data->face = NULL; +#ifdef HAVE_MMAP + data->blob.bytes = _mmap_bytes (tmpl.bytes, tmpl.len); + if (data->blob.bytes != MAP_FAILED) { + data->source = NULL; + if (--string->base.ref == 0) + csi_string_free (ctx, string); + } else { + data->blob.bytes = tmpl.bytes; + data->source = string; + } +#else + data->blob.bytes = tmpl.bytes; data->source = string; +#endif status = cairo_font_face_set_user_data (font_face, &_csi_blob_key,