From aa7668835afffd5a2a496a60ed6edb672f5af1a7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 21 Sep 2011 15:01:36 +0200 Subject: Rename malloc functions for arrays (fz_calloc and fz_realloc). --- pdf/pdf_cmap.c | 4 ++-- pdf/pdf_colorspace.c | 2 +- pdf/pdf_font.c | 6 +++--- pdf/pdf_function.c | 10 +++++----- pdf/pdf_image.c | 2 +- pdf/pdf_metrics.c | 4 ++-- pdf/pdf_page.c | 8 ++++---- pdf/pdf_parse.c | 6 +++--- pdf/pdf_repair.c | 4 ++-- pdf/pdf_shade.c | 6 +++--- pdf/pdf_unicode.c | 2 +- pdf/pdf_xref.c | 6 +++--- 12 files changed, 30 insertions(+), 30 deletions(-) (limited to 'pdf') diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index 0c446470..3de3346b 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -189,7 +189,7 @@ add_table(fz_context *ctx, pdf_cmap *cmap, int value) if (cmap->tlen + 1 > cmap->tcap) { cmap->tcap = cmap->tcap > 1 ? (cmap->tcap * 3) / 2 : 256; - cmap->table = fz_realloc(ctx, cmap->table, cmap->tcap * sizeof(unsigned short)); + cmap->table = fz_resize_array(ctx, cmap->table, cmap->tcap, sizeof(unsigned short)); } cmap->table[cmap->tlen++] = value; } @@ -210,7 +210,7 @@ add_range(fz_context *ctx, pdf_cmap *cmap, int low, int high, int flag, int offs if (cmap->rlen + 1 > cmap->rcap) { cmap->rcap = cmap->rcap > 1 ? (cmap->rcap * 3) / 2 : 256; - cmap->ranges = fz_realloc(ctx, cmap->ranges, cmap->rcap * sizeof(pdf_range)); + cmap->ranges = fz_resize_array(ctx, cmap->ranges, cmap->rcap, sizeof(pdf_range)); } cmap->ranges[cmap->rlen].low = low; pdf_range_set_high(&cmap->ranges[cmap->rlen], high); diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c index 56a54e5c..1a2e79b3 100644 --- a/pdf/pdf_colorspace.c +++ b/pdf/pdf_colorspace.c @@ -230,7 +230,7 @@ load_indexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) idx->high = fz_to_int(highobj); idx->high = CLAMP(idx->high, 0, 255); n = base->n * (idx->high + 1); - idx->lookup = fz_calloc(ctx, 1, n); + idx->lookup = fz_malloc_array(ctx, 1, n); cs = fz_new_colorspace(ctx, "Indexed", 1); cs->to_rgb = indexed_to_rgb; diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index ad5b8d97..e1cae007 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -504,7 +504,7 @@ pdf_load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict) else fz_warn("freetype could not find any cmaps"); - etable = fz_calloc(ctx, 256, sizeof(unsigned short)); + etable = fz_malloc_array(ctx, 256, sizeof(unsigned short)); for (i = 0; i < 256; i++) { estrings[i] = NULL; @@ -800,7 +800,7 @@ load_cid_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *e goto cleanup; fontdesc->cid_to_gid_len = (buf->len) / 2; - fontdesc->cid_to_gid = fz_calloc(ctx, fontdesc->cid_to_gid_len, sizeof(unsigned short)); + fontdesc->cid_to_gid = fz_malloc_array(ctx, fontdesc->cid_to_gid_len, sizeof(unsigned short)); for (i = 0; i < fontdesc->cid_to_gid_len; i++) fontdesc->cid_to_gid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1]; @@ -1067,7 +1067,7 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc) } font->width_count ++; - font->width_table = fz_calloc(ctx, font->width_count, sizeof(int)); + font->width_table = fz_malloc_array(ctx, font->width_count, sizeof(int)); for (i = 0; i < fontdesc->hmtx_len; i++) { diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 7ab681c3..50b09926 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -677,7 +677,7 @@ resize_code(fz_context *ctx, pdf_function *func, int newsize) if (newsize >= func->u.p.cap) { func->u.p.cap = func->u.p.cap + 64; - func->u.p.code = fz_realloc(ctx, func->u.p.code, func->u.p.cap * sizeof(psobj)); + func->u.p.code = fz_resize_array(ctx, func->u.p.code, func->u.p.cap, sizeof(psobj)); } } @@ -960,7 +960,7 @@ load_sample_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int for (i = 0, samplecount = func->n; i < func->m; i++) samplecount *= func->u.sa.size[i]; - func->u.sa.samples = fz_calloc(ctx, samplecount, sizeof(float)); + func->u.sa.samples = fz_malloc_array(ctx, samplecount, sizeof(float)); error = pdf_open_stream(&stream, xref, num, gen); if (error) @@ -1206,9 +1206,9 @@ load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict) { k = fz_array_len(obj); - func->u.st.funcs = fz_calloc(ctx, k, sizeof(pdf_function*)); - func->u.st.bounds = fz_calloc(ctx, k - 1, sizeof(float)); - func->u.st.encode = fz_calloc(ctx, k * 2, sizeof(float)); + func->u.st.funcs = fz_malloc_array(ctx, k, sizeof(pdf_function*)); + func->u.st.bounds = fz_malloc_array(ctx, k - 1, sizeof(float)); + func->u.st.encode = fz_malloc_array(ctx, k * 2, sizeof(float)); funcs = func->u.st.funcs; for (i = 0; i < k; i++) diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index cb63309d..c5242b72 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -191,7 +191,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, } } - samples = fz_calloc(ctx, h, stride); + samples = fz_malloc_array(ctx, h, stride); len = fz_read(stm, samples, h * stride); if (len < 0) diff --git a/pdf/pdf_metrics.c b/pdf/pdf_metrics.c index 62353f9f..3aa0ef24 100644 --- a/pdf/pdf_metrics.c +++ b/pdf/pdf_metrics.c @@ -26,7 +26,7 @@ pdf_add_hmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int w) if (font->hmtx_len + 1 >= font->hmtx_cap) { font->hmtx_cap = font->hmtx_cap + 16; - font->hmtx = fz_realloc(ctx, font->hmtx, font->hmtx_cap * sizeof(pdf_hmtx)); + font->hmtx = fz_resize_array(ctx, font->hmtx, font->hmtx_cap, sizeof(pdf_hmtx)); } font->hmtx[font->hmtx_len].lo = lo; @@ -41,7 +41,7 @@ pdf_add_vmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int x, int y, if (font->vmtx_len + 1 >= font->vmtx_cap) { font->vmtx_cap = font->vmtx_cap + 16; - font->vmtx = fz_realloc(ctx, font->vmtx, font->vmtx_cap * sizeof(pdf_vmtx)); + font->vmtx = fz_resize_array(ctx, font->vmtx, font->vmtx_cap, sizeof(pdf_vmtx)); } font->vmtx[font->vmtx_len].lo = lo; diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index 88825531..7c8fb88e 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -85,8 +85,8 @@ pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info) { fz_warn("found more pages than expected"); xref->page_cap ++; - xref->page_refs = fz_realloc(ctx, xref->page_refs, xref->page_cap * sizeof(fz_obj*)); - xref->page_objs = fz_realloc(ctx, xref->page_objs, xref->page_cap * sizeof(fz_obj*)); + xref->page_refs = fz_resize_array(ctx, xref->page_refs, xref->page_cap, sizeof(fz_obj*)); + xref->page_objs = fz_resize_array(ctx, xref->page_objs, xref->page_cap, sizeof(fz_obj*)); } xref->page_refs[xref->page_len] = fz_keep_obj(node); @@ -111,8 +111,8 @@ pdf_load_page_tree(pdf_xref *xref) xref->page_cap = fz_to_int(count); xref->page_len = 0; - xref->page_refs = fz_calloc(ctx, xref->page_cap, sizeof(fz_obj*)); - xref->page_objs = fz_calloc(ctx, xref->page_cap, sizeof(fz_obj*)); + xref->page_refs = fz_malloc_array(ctx, xref->page_cap, sizeof(fz_obj*)); + xref->page_objs = fz_malloc_array(ctx, xref->page_cap, sizeof(fz_obj*)); info.resources = NULL; info.mediabox = NULL; diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index 04c67eca..b1f22e46 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -101,19 +101,19 @@ pdf_to_ucs2(fz_context *ctx, fz_obj *src) if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) { - dstptr = dst = fz_calloc(ctx, (srclen - 2) / 2 + 1, sizeof(short)); + dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); for (i = 2; i + 1 < srclen; i += 2) *dstptr++ = srcptr[i] << 8 | srcptr[i+1]; } else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254) { - dstptr = dst = fz_calloc(ctx, (srclen - 2) / 2 + 1, sizeof(short)); + dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); for (i = 2; i + 1 < srclen; i += 2) *dstptr++ = srcptr[i] | srcptr[i+1] << 8; } else { - dstptr = dst = fz_calloc(ctx, srclen + 1, sizeof(short)); + dstptr = dst = fz_malloc_array(ctx, srclen + 1, sizeof(short)); for (i = 0; i < srclen; i++) *dstptr++ = pdf_doc_encoding[srcptr[i]]; } diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 83b0d814..461fd4de 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -208,7 +208,7 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) listlen = 0; listcap = 1024; - list = fz_calloc(ctx, listcap, sizeof(struct entry)); + list = fz_malloc_array(ctx, listcap, sizeof(struct entry)); /* look for '%PDF' version marker within first kilobyte of file */ n = fz_read(xref->file, (unsigned char *)buf, MAX(bufsize, 1024)); @@ -271,7 +271,7 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) if (listlen + 1 == listcap) { listcap = (listcap * 3) / 2; - list = fz_realloc(ctx, list, listcap * sizeof(struct entry)); + list = fz_resize_array(ctx, list, listcap, sizeof(struct entry)); } list[listlen].num = num; diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c index a6819521..45fefba5 100644 --- a/pdf/pdf_shade.c +++ b/pdf/pdf_shade.c @@ -24,7 +24,7 @@ pdf_grow_mesh(fz_context *ctx, fz_shade *shade, int amount) while (shade->mesh_len + amount > shade->mesh_cap) shade->mesh_cap = (shade->mesh_cap * 3) / 2; - shade->mesh = fz_realloc(ctx, shade->mesh, shade->mesh_cap * sizeof(float)); + shade->mesh = fz_resize_array(ctx, shade->mesh, shade->mesh_cap, sizeof(float)); } static void @@ -688,8 +688,8 @@ pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, else ncomp = shade->colorspace->n; - ref = fz_calloc(ctx, p.vprow, sizeof(struct vertex)); - buf = fz_calloc(ctx, p.vprow, sizeof(struct vertex)); + ref = fz_malloc_array(ctx, p.vprow, sizeof(struct vertex)); + buf = fz_malloc_array(ctx, p.vprow, sizeof(struct vertex)); first = 1; while (!fz_is_eof_bits(stream)) diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c index 25781e1c..46c68a52 100644 --- a/pdf/pdf_unicode.c +++ b/pdf/pdf_unicode.c @@ -63,7 +63,7 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, /* TODO one-to-many mappings */ font->cid_to_ucs_len = 256; - font->cid_to_ucs = fz_calloc(ctx, 256, sizeof(unsigned short)); + font->cid_to_ucs = fz_malloc_array(ctx, 256, sizeof(unsigned short)); for (i = 0; i < 256; i++) { diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index d259e6d0..b514c193 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -172,7 +172,7 @@ pdf_resize_xref(pdf_xref *xref, int newlen) { int i; - xref->table = fz_realloc(xref->ctx, xref->table, newlen * sizeof(pdf_xref_entry)); + xref->table = fz_resize_array(xref->ctx, xref->table, newlen, sizeof(pdf_xref_entry)); for (i = xref->len; i < newlen; i++) { xref->table[i].type = 0; @@ -726,8 +726,8 @@ pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) count = fz_to_int(fz_dict_gets(objstm, "N")); first = fz_to_int(fz_dict_gets(objstm, "First")); - numbuf = fz_calloc(ctx, count, sizeof(int)); - ofsbuf = fz_calloc(ctx, count, sizeof(int)); + numbuf = fz_malloc_array(ctx, count, sizeof(int)); + ofsbuf = fz_malloc_array(ctx, count, sizeof(int)); error = pdf_open_stream(&stm, xref, num, gen); if (error) -- cgit v1.2.3