summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xps/muxps.h8
-rw-r--r--xps/xpscolor.c2
-rw-r--r--xps/xpscrc.c81
-rw-r--r--xps/xpsdoc.c32
-rw-r--r--xps/xpsglyphs.c2
-rw-r--r--xps/xpshash.c14
-rw-r--r--xps/xpsimage.c14
-rw-r--r--xps/xpsjxr.c4
-rw-r--r--xps/xpsmem.c62
-rw-r--r--xps/xpspage.c2
-rw-r--r--xps/xpspath.c2
-rw-r--r--xps/xpspng.c4
-rw-r--r--xps/xpsresource.c12
-rw-r--r--xps/xpstiff.c26
-rw-r--r--xps/xpsxml.c2
-rw-r--r--xps/xpszip.c26
16 files changed, 75 insertions, 218 deletions
diff --git a/xps/muxps.h b/xps/muxps.h
index 37dd03c6..c778be37 100644
--- a/xps/muxps.h
+++ b/xps/muxps.h
@@ -29,15 +29,7 @@ typedef struct xps_context_s xps_context;
* Memory, and string functions.
*/
-#define xps_alloc(ctx, size) fz_malloc(size)
-#define xps_realloc(ctx, ptr, size) fz_realloc(ptr, size, 1)
-#define xps_strdup(ctx, str) fz_strdup(str)
-#define xps_free(ctx, ptr) fz_free(ptr)
-
-int xps_strlcpy(char *destination, const char *source, int size);
-int xps_strlcat(char *destination, const char *source, int size);
int xps_strcasecmp(char *a, char *b);
-char *xps_strdup_imp(xps_context *ctx, const char *str, const char *function);
void xps_absolute_path(char *output, char *base_uri, char *path, int output_size);
int xps_utf8_to_ucs(int *p, const char *s, int n);
diff --git a/xps/xpscolor.c b/xps/xpscolor.c
index 513e7aab..bb2f225f 100644
--- a/xps/xpscolor.c
+++ b/xps/xpscolor.c
@@ -191,7 +191,7 @@ xps_read_icc_colorspace(xps_context *ctx, char *base_uri, char *profilename)
xps_free_part(ctx, part);
/* Add colorspace to xps color cache. */
- xps_hash_insert(ctx, ctx->colorspace_table, xps_strdup(ctx, partname), space);
+ xps_hash_insert(ctx, ctx->colorspace_table, fz_strdup(partname), space);
}
return space;
diff --git a/xps/xpscrc.c b/xps/xpscrc.c
deleted file mode 100644
index d5d4acd8..00000000
--- a/xps/xpscrc.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "fitz.h"
-#include "muxps.h"
-
-static const unsigned long crctab[256] =
-{
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- 0x2d02ef8dL
-};
-
-#define DO1(buf) crc = crctab[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
-#define DO2(buf) DO1(buf); DO1(buf);
-#define DO4(buf) DO2(buf); DO2(buf);
-#define DO8(buf) DO4(buf); DO4(buf);
-
-unsigned int
-xps_crc32(unsigned int crc, unsigned char *buf, int len)
-{
- if (buf == NULL)
- return 0L;
- crc = crc ^ 0xffffffffL;
- while (len >= 8)
- {
- DO8(buf);
- len -= 8;
- }
- if (len)
- {
- do { DO1(buf); } while (--len);
- }
- return crc ^ 0xffffffffL;
-}
diff --git a/xps/xpsdoc.c b/xps/xpsdoc.c
index 312cac8d..a37ed0e9 100644
--- a/xps/xpsdoc.c
+++ b/xps/xpsdoc.c
@@ -8,10 +8,10 @@ xps_new_part(xps_context *ctx, char *name, int size)
{
xps_part *part;
- part = xps_alloc(ctx, sizeof(xps_part));
- part->name = xps_strdup(ctx, name);
+ part = fz_malloc(sizeof(xps_part));
+ part->name = fz_strdup(name);
part->size = size;
- part->data = xps_alloc(ctx, size);
+ part->data = fz_malloc(size);
return part;
}
@@ -19,9 +19,9 @@ xps_new_part(xps_context *ctx, char *name, int size)
void
xps_free_part(xps_context *ctx, xps_part *part)
{
- xps_free(ctx, part->name);
- xps_free(ctx, part->data);
- xps_free(ctx, part);
+ fz_free(part->name);
+ fz_free(part->data);
+ fz_free(part);
}
/*
@@ -61,8 +61,8 @@ xps_add_fixed_document(xps_context *ctx, char *name)
if (!strcmp(fixdoc->name, name))
return;
- fixdoc = xps_alloc(ctx, sizeof(xps_document));
- fixdoc->name = xps_strdup(ctx, name);
+ fixdoc = fz_malloc(sizeof(xps_document));
+ fixdoc->name = fz_strdup(name);
fixdoc->next = NULL;
if (!ctx->first_fixdoc)
@@ -84,8 +84,8 @@ xps_free_fixed_documents(xps_context *ctx)
while (node)
{
xps_document *next = node->next;
- xps_free(ctx, node->name);
- xps_free(ctx, node);
+ fz_free(node->name);
+ fz_free(node);
node = next;
}
ctx->first_fixdoc = NULL;
@@ -102,8 +102,8 @@ xps_add_fixed_page(xps_context *ctx, char *name, int width, int height)
if (!strcmp(page->name, name))
return;
- page = xps_alloc(ctx, sizeof(xps_page));
- page->name = xps_strdup(ctx, name);
+ page = fz_malloc(sizeof(xps_page));
+ page->name = fz_strdup(name);
page->width = width;
page->height = height;
page->root = NULL;
@@ -128,8 +128,8 @@ xps_free_fixed_pages(xps_context *ctx)
while (node)
{
xps_page *next = node->next;
- xps_free(ctx, node->name);
- xps_free(ctx, node);
+ fz_free(node->name);
+ fz_free(node);
node = next;
}
ctx->first_page = NULL;
@@ -166,7 +166,7 @@ xps_parse_metadata_imp(void *zp, char *name, char **atts)
{
xps_absolute_path(tgtbuf, ctx->base_uri, target, sizeof tgtbuf);
if (!strcmp(type, REL_START_PART))
- ctx->start_part = xps_strdup(ctx, tgtbuf);
+ ctx->start_part = fz_strdup(tgtbuf);
}
}
@@ -222,7 +222,7 @@ xps_parse_metadata(xps_context *ctx, xps_part *part)
char *s;
/* Save directory name part */
- xps_strlcpy(buf, part->name, sizeof buf);
+ fz_strlcpy(buf, part->name, sizeof buf);
s = strrchr(buf, '/');
if (s)
s[0] = 0;
diff --git a/xps/xpsglyphs.c b/xps/xpsglyphs.c
index c53e3a25..834a55f5 100644
--- a/xps/xpsglyphs.c
+++ b/xps/xpsglyphs.c
@@ -425,7 +425,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm,
xps_hash_insert(ctx, ctx->font_table, part->name, font);
/* NOTE: we kept part->name in the hashtable and part->data in the font */
- xps_free(ctx, part);
+ fz_free(part);
}
/*
diff --git a/xps/xpshash.c b/xps/xpshash.c
index 24d05074..0fdf59db 100644
--- a/xps/xpshash.c
+++ b/xps/xpshash.c
@@ -52,7 +52,7 @@ xps_hash_new(xps_context *ctx)
{
xps_hash_table *table;
- table = xps_alloc(ctx, sizeof(xps_hash_table));
+ table = fz_malloc(sizeof(xps_hash_table));
if (!table)
{
fz_throw("out of memory: hash table struct");
@@ -62,10 +62,10 @@ xps_hash_new(xps_context *ctx)
table->size = primes[0];
table->load = 0;
- table->entries = xps_alloc(ctx, sizeof(xps_hash_entry) * table->size);
+ table->entries = fz_malloc(sizeof(xps_hash_entry) * table->size);
if (!table->entries)
{
- xps_free(ctx, table);
+ fz_free(table);
fz_throw("out of memory: hash table entries array");
return NULL;
}
@@ -94,7 +94,7 @@ xps_hash_double(xps_context *ctx, xps_hash_table *table)
}
old_entries = table->entries;
- new_entries = xps_alloc(ctx, sizeof(xps_hash_entry) * new_size);
+ new_entries = fz_malloc(sizeof(xps_hash_entry) * new_size);
if (!new_entries)
return fz_throw("out of memory: hash table entries array");
@@ -108,7 +108,7 @@ xps_hash_double(xps_context *ctx, xps_hash_table *table)
if (old_entries[i].value)
xps_hash_insert(ctx, table, old_entries[i].key, old_entries[i].value);
- xps_free(ctx, old_entries);
+ fz_free(old_entries);
return 0;
}
@@ -128,8 +128,8 @@ xps_hash_free(xps_context *ctx, xps_hash_table *table,
free_value(ctx, table->entries[i].value);
}
- xps_free(ctx, table->entries);
- xps_free(ctx, table);
+ fz_free(table->entries);
+ fz_free(table);
}
void *
diff --git a/xps/xpsimage.c b/xps/xpsimage.c
index 6866518f..8add170e 100644
--- a/xps/xpsimage.c
+++ b/xps/xpsimage.c
@@ -146,7 +146,7 @@ xps_find_image_brush_source_part(xps_context *ctx, char *base_uri, xps_item *roo
image_name = NULL;
profile_name = NULL;
- xps_strlcpy(buf, image_source_att, sizeof buf);
+ fz_strlcpy(buf, image_source_att, sizeof buf);
p = strchr(buf, ' ');
if (p)
{
@@ -178,7 +178,7 @@ xps_find_image_brush_source_part(xps_context *ctx, char *base_uri, xps_item *roo
*partp = part;
if (profile_name)
- *profilep = xps_strdup(ctx, profile_name);
+ *profilep = fz_strdup(profile_name);
return 0;
}
@@ -200,7 +200,7 @@ xps_parse_image_brush(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resou
return;
}
- image = xps_alloc(ctx, sizeof(xps_image));
+ image = fz_malloc(sizeof(xps_image));
code = xps_decode_image(ctx, part, image);
if (code < 0) {
@@ -223,7 +223,7 @@ xps_parse_image_brush(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resou
xps_parse_tiling_brush(ctx, ctm, base_uri, dict, root, xps_paint_image_brush, image);
if (profilename)
- xps_free(ctx, profilename);
+ fz_free(profilename);
xps_free_image(ctx, image);
xps_free_part(ctx, part);
}
@@ -233,8 +233,8 @@ xps_free_image(xps_context *ctx, xps_image *image)
{
// TODO: refcount image->colorspace
if (image->samples)
- xps_free(ctx, image->samples);
+ fz_free(image->samples);
if (image->profile)
- xps_free(ctx, image->profile);
- xps_free(ctx, image);
+ fz_free(image->profile);
+ fz_free(image);
}
diff --git a/xps/xpsjxr.c b/xps/xpsjxr.c
index db0792ae..2ca9a22b 100644
--- a/xps/xpsjxr.c
+++ b/xps/xpsjxr.c
@@ -84,7 +84,7 @@ xps_decode_jpegxr_block(jxr_image image, int mx, int my, int *data)
output->hasalpha = jxr_get_ALPHACHANNEL_FLAG(image);
output->bits = 8;
output->stride = output->width * output->comps;
- output->samples = xps_alloc(ctx, output->stride * output->height);
+ output->samples = fz_malloc(output->stride * output->height);
switch (output->comps)
{
@@ -128,7 +128,7 @@ xps_decode_jpegxr_alpha_block(jxr_image image, int mx, int my, int *data)
if (!output->alpha)
{
- output->alpha = xps_alloc(ctx, output->width * output->height);
+ output->alpha = fz_malloc(output->width * output->height);
}
depth = jxr_get_OUTPUT_BITDEPTH(image);
diff --git a/xps/xpsmem.c b/xps/xpsmem.c
index baae4e80..a85b2117 100644
--- a/xps/xpsmem.c
+++ b/xps/xpsmem.c
@@ -21,60 +21,6 @@ xps_strcasecmp(char *a, char *b)
return xps_tolower(*a) - xps_tolower(*b);
}
-int
-xps_strlcpy(char *dst, const char *src, int size)
-{
- register char *d = dst;
- register const char *s = src;
- register int n = size;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (size != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-
-int
-xps_strlcat(char *dst, const char *src, int size)
-{
- register char *d = dst;
- register const char *s = src;
- register int n = size;
- int dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
- d++;
- dlen = d - dst;
- n = size - dlen;
-
- if (n == 0)
- return dlen + strlen(s);
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return dlen + (s - src); /* count does not include NUL */
-}
-
#define SEP(x) ((x)=='/' || (x) == 0)
static char *
@@ -137,13 +83,13 @@ xps_absolute_path(char *output, char *base_uri, char *path, int output_size)
{
if (path[0] == '/')
{
- xps_strlcpy(output, path, output_size);
+ fz_strlcpy(output, path, output_size);
}
else
{
- xps_strlcpy(output, base_uri, output_size);
- xps_strlcat(output, "/", output_size);
- xps_strlcat(output, path, output_size);
+ fz_strlcpy(output, base_uri, output_size);
+ fz_strlcat(output, "/", output_size);
+ fz_strlcat(output, path, output_size);
}
xps_clean_path(output);
}
diff --git a/xps/xpspage.c b/xps/xpspage.c
index aa5a96b4..32439f19 100644
--- a/xps/xpspage.c
+++ b/xps/xpspage.c
@@ -94,7 +94,7 @@ xps_parse_fixed_page(xps_context *ctx, fz_matrix ctm, xps_page *page)
char *s;
int code;
- xps_strlcpy(base_uri, page->name, sizeof base_uri);
+ fz_strlcpy(base_uri, page->name, sizeof base_uri);
s = strrchr(base_uri, '/');
if (s)
s[1] = 0;
diff --git a/xps/xpspath.c b/xps/xpspath.c
index c0f45527..86d37197 100644
--- a/xps/xpspath.c
+++ b/xps/xpspath.c
@@ -485,7 +485,7 @@ xps_parse_abbreviated_geometry(xps_context *ctx, char *geom)
old = cmd;
}
- xps_free(ctx, args);
+ fz_free(args);
}
static void
diff --git a/xps/xpspng.c b/xps/xpspng.c
index bfe6f85a..526a5098 100644
--- a/xps/xpspng.c
+++ b/xps/xpspng.c
@@ -190,7 +190,7 @@ xps_decode_png(xps_context *ctx, byte *rbuf, int rlen, xps_image *image)
if (info->iccp_profile != NULL)
{
image->profilesize = info->iccp_proflen;
- image->profile = xps_alloc(ctx, info->iccp_proflen);
+ image->profile = fz_malloc(info->iccp_proflen);
if (image->profile)
{
/* If we can't create it, just ignore */
@@ -249,7 +249,7 @@ xps_decode_png(xps_context *ctx, byte *rbuf, int rlen, xps_image *image)
image->stride = (image->width * image->comps * image->bits + 7) / 8;
- image->samples = xps_alloc(ctx, image->stride * image->height);
+ image->samples = fz_malloc(image->stride * image->height);
for (pass = 0; pass < npasses; pass++)
{
diff --git a/xps/xpsresource.c b/xps/xpsresource.c
index 631b6cb7..bda624e6 100644
--- a/xps/xpsresource.c
+++ b/xps/xpsresource.c
@@ -29,7 +29,7 @@ xps_parse_resource_reference(xps_context *ctx, xps_resource *dict, char *att, ch
if (strstr(att, "{StaticResource ") != att)
return NULL;
- xps_strlcpy(name, att + 16, sizeof name);
+ fz_strlcpy(name, att + 16, sizeof name);
s = strrchr(name, '}');
if (s)
*s = 0;
@@ -85,7 +85,7 @@ xps_parse_remote_resource_dictionary(xps_context *ctx, xps_resource **dictp, cha
return fz_throw("expected ResourceDictionary element (found %s)", xps_tag(xml));
}
- xps_strlcpy(part_uri, part_name, sizeof part_uri);
+ fz_strlcpy(part_uri, part_name, sizeof part_uri);
s = strrchr(part_uri, '/');
if (s)
s[1] = 0;
@@ -133,7 +133,7 @@ xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base
key = xps_att(node, "Key");
if (key)
{
- entry = xps_alloc(ctx, sizeof(xps_resource));
+ entry = fz_malloc(sizeof(xps_resource));
if (!entry)
return fz_throw("cannot allocate resource entry");
entry->name = key;
@@ -148,7 +148,7 @@ xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base
if (head)
{
- head->base_uri = xps_strdup(ctx, base_uri);
+ head->base_uri = fz_strdup(base_uri);
}
*dictp = head;
@@ -165,8 +165,8 @@ xps_free_resource_dictionary(xps_context *ctx, xps_resource *dict)
if (dict->base_xml)
xps_free_item(ctx, dict->base_xml);
if (dict->base_uri)
- xps_free(ctx, dict->base_uri);
- xps_free(ctx, dict);
+ fz_free(dict->base_uri);
+ fz_free(dict);
dict = next;
}
}
diff --git a/xps/xpstiff.c b/xps/xpstiff.c
index 6d6050e6..7ab684fc 100644
--- a/xps/xpstiff.c
+++ b/xps/xpstiff.c
@@ -538,7 +538,7 @@ xps_expand_colormap(xps_context *ctx, xps_tiff *tiff, xps_image *image)
stride = image->width * (image->comps + 2);
- samples = xps_alloc(ctx, stride * image->height);
+ samples = fz_malloc(stride * image->height);
if (!samples)
return fz_throw("out of memory: samples");
@@ -655,7 +655,7 @@ xps_decode_tiff_strips(xps_context *ctx, xps_tiff *tiff, xps_image *image)
image->yres = 96;
}
- image->samples = xps_alloc(ctx, image->stride * image->height);
+ image->samples = fz_malloc(image->stride * image->height);
if (!image->samples)
return fz_throw("could not allocate image samples");
@@ -887,7 +887,7 @@ xps_read_tiff_tag(xps_context *ctx, xps_tiff *tiff, unsigned offset)
xps_read_tiff_tag_value(&tiff->extrasamples, tiff, type, value, 1);
break;
case ICCProfile:
- tiff->profile = xps_alloc(ctx, count);
+ tiff->profile = fz_malloc(count);
if (!tiff->profile)
return fz_throw("could not allocate embedded icc profile");
/* ICC profile data type is set to UNDEFINED.
@@ -902,21 +902,21 @@ xps_read_tiff_tag(xps_context *ctx, xps_tiff *tiff, unsigned offset)
break;
case StripOffsets:
- tiff->stripoffsets = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned));
+ tiff->stripoffsets = (unsigned*) fz_malloc(count * sizeof(unsigned));
if (!tiff->stripoffsets)
return fz_throw("could not allocate strip offsets");
xps_read_tiff_tag_value(tiff->stripoffsets, tiff, type, value, count);
break;
case StripByteCounts:
- tiff->stripbytecounts = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned));
+ tiff->stripbytecounts = (unsigned*) fz_malloc(count * sizeof(unsigned));
if (!tiff->stripbytecounts)
return fz_throw("could not allocate strip byte counts");
xps_read_tiff_tag_value(tiff->stripbytecounts, tiff, type, value, count);
break;
case ColorMap:
- tiff->colormap = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned));
+ tiff->colormap = (unsigned*) fz_malloc(count * sizeof(unsigned));
if (!tiff->colormap)
return fz_throw("could not allocate color map");
xps_read_tiff_tag_value(tiff->colormap, tiff, type, value, count);
@@ -1055,9 +1055,9 @@ xps_decode_tiff(xps_context *ctx, byte *buf, int len, xps_image *image)
* Clean up scratch memory
*/
- if (tiff->colormap) xps_free(ctx, tiff->colormap);
- if (tiff->stripoffsets) xps_free(ctx, tiff->stripoffsets);
- if (tiff->stripbytecounts) xps_free(ctx, tiff->stripbytecounts);
+ if (tiff->colormap) fz_free(tiff->colormap);
+ if (tiff->stripoffsets) fz_free(tiff->stripoffsets);
+ if (tiff->stripbytecounts) fz_free(tiff->stripbytecounts);
return gs_okay;
}
@@ -1076,10 +1076,10 @@ xps_tiff_has_alpha(xps_context *ctx, byte *buf, int len)
return 0;
}
- if (tiff->profile) xps_free(ctx, tiff->profile);
- if (tiff->colormap) xps_free(ctx, tiff->colormap);
- if (tiff->stripoffsets) xps_free(ctx, tiff->stripoffsets);
- if (tiff->stripbytecounts) xps_free(ctx, tiff->stripbytecounts);
+ if (tiff->profile) fz_free(tiff->profile);
+ if (tiff->colormap) fz_free(tiff->colormap);
+ if (tiff->stripoffsets) fz_free(tiff->stripoffsets);
+ if (tiff->stripbytecounts) fz_free(tiff->stripbytecounts);
return tiff->extrasamples == 2 || tiff->extrasamples == 1;
}
diff --git a/xps/xpsxml.c b/xps/xpsxml.c
index 70dbe49d..63d9af36 100644
--- a/xps/xpsxml.c
+++ b/xps/xpsxml.c
@@ -285,7 +285,7 @@ xps_free_item(xps_context *ctx, xps_item *item)
next = item->next;
if (item->down)
xps_free_item(ctx, item->down);
- xps_free(ctx, item);
+ fz_free(item);
item = next;
}
}
diff --git a/xps/xpszip.c b/xps/xpszip.c
index d3c03103..a02ce302 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -22,13 +22,13 @@ static inline int getlong(FILE *file)
static void *
xps_zip_alloc_items(xps_context *ctx, int items, int size)
{
- return xps_alloc(ctx, items * size);
+ return fz_malloc(items * size);
}
static void
xps_zip_free(xps_context *ctx, void *ptr)
{
- xps_free(ctx, ptr);
+ fz_free(ptr);
}
static int
@@ -97,7 +97,7 @@ xps_read_zip_entry(xps_context *ctx, xps_entry *ent, unsigned char *outbuf)
}
else if (method == 8)
{
- inbuf = xps_alloc(ctx, ent->csize);
+ inbuf = fz_malloc(ent->csize);
fread(inbuf, 1, ent->csize, ctx->file);
@@ -123,7 +123,7 @@ xps_read_zip_entry(xps_context *ctx, xps_entry *ent, unsigned char *outbuf)
if (code != Z_OK)
return fz_throw("zlib inflateEnd error: %s", stream.msg);
- xps_free(ctx, inbuf);
+ fz_free(inbuf);
}
else
{
@@ -159,7 +159,7 @@ xps_read_zip_dir(xps_context *ctx, int start_offset)
offset = getlong(ctx->file); /* offset to central directory */
ctx->zip_count = count;
- ctx->zip_table = xps_alloc(ctx, sizeof(xps_entry) * count);
+ ctx->zip_table = fz_malloc(sizeof(xps_entry) * count);
if (!ctx->zip_table)
return fz_throw("cannot allocate zip entry table");
@@ -190,7 +190,7 @@ xps_read_zip_dir(xps_context *ctx, int start_offset)
(void) getlong(ctx->file); /* ext file atts */
ctx->zip_table[i].offset = getlong(ctx->file);
- ctx->zip_table[i].name = xps_alloc(ctx, namesize + 1);
+ ctx->zip_table[i].name = fz_malloc(namesize + 1);
if (!ctx->zip_table[i].name)
return fz_throw("cannot allocate zip entry name");
@@ -314,8 +314,8 @@ xps_read_dir_part(xps_context *ctx, char *name)
FILE *file;
int count, size, offset, i, n;
- xps_strlcpy(buf, ctx->directory, sizeof buf);
- xps_strlcat(buf, name, sizeof buf);
+ fz_strlcpy(buf, ctx->directory, sizeof buf);
+ fz_strlcat(buf, name, sizeof buf);
/* All in one piece */
file = fopen(buf, "rb");
@@ -421,12 +421,12 @@ xps_open_file(xps_context *ctx, char *filename)
if (strstr(filename, "/_rels/.rels") || strstr(filename, "\\_rels\\.rels"))
{
- xps_strlcpy(buf, filename, sizeof buf);
+ fz_strlcpy(buf, filename, sizeof buf);
p = strstr(buf, "/_rels/.rels");
if (!p)
p = strstr(buf, "\\_rels\\.rels");
*p = 0;
- ctx->directory = xps_strdup(ctx, buf);
+ ctx->directory = fz_strdup(buf);
}
else
{
@@ -516,7 +516,7 @@ xps_new_context(void)
static void xps_free_key_func(xps_context *ctx, void *ptr)
{
- xps_free(ctx, ptr);
+ fz_free(ptr);
}
static void xps_free_font_func(xps_context *ctx, void *ptr)
@@ -534,8 +534,8 @@ xps_free_context(xps_context *ctx)
fclose(ctx->file);
for (i = 0; i < ctx->zip_count; i++)
- xps_free(ctx, ctx->zip_table[i].name);
- xps_free(ctx, ctx->zip_table);
+ fz_free(ctx->zip_table[i].name);
+ fz_free(ctx->zip_table);
/* TODO: free resources too */
xps_hash_free(ctx, ctx->font_table, xps_free_key_func, xps_free_font_func);