summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'fitz')
-rw-r--r--fitz/fitz_tree.h2
-rw-r--r--fitz/obj_array.c7
-rw-r--r--fitz/obj_dict.c7
-rw-r--r--fitz/obj_print.c2
-rw-r--r--fitz/res_font.c30
-rw-r--r--fitz/stm_buffer.c5
6 files changed, 13 insertions, 40 deletions
diff --git a/fitz/fitz_tree.h b/fitz/fitz_tree.h
index 68cfe6d7..95044a4e 100644
--- a/fitz/fitz_tree.h
+++ b/fitz/fitz_tree.h
@@ -369,7 +369,7 @@ struct fz_glyph_s
fz_error fz_newfreetypefont(fz_font **fontp, char *name, int substitute);
fz_error fz_loadfreetypefontfile(fz_font *font, char *path, int index);
fz_error fz_loadfreetypefontbuffer(fz_font *font, unsigned char *data, int len, int index);
-fz_error fz_newtype3font(fz_font **fontp, char *name, fz_matrix matrix);
+fz_font * fz_newtype3font(char *name, fz_matrix matrix);
fz_error fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index);
fz_error fz_newfontfromfile(fz_font **fontp, char *path, int index);
diff --git a/fitz/obj_array.c b/fitz/obj_array.c
index ac1e1fa8..07916aa2 100644
--- a/fitz/obj_array.c
+++ b/fitz/obj_array.c
@@ -96,11 +96,10 @@ fz_arraypush(fz_obj *obj, fz_obj *item)
if (obj->u.a.len + 1 > obj->u.a.cap)
{
int i;
- int newcap = obj->u.a.cap * 2;
- obj->u.a.items = fz_realloc(obj->u.a.items, sizeof (fz_obj*) * newcap);
- for (i = obj->u.a.cap ; i < newcap; i++)
+ obj->u.a.cap = (obj->u.a.cap * 3) / 2;
+ obj->u.a.items = fz_realloc(obj->u.a.items, sizeof (fz_obj*) * obj->u.a.cap);
+ for (i = obj->u.a.len ; i < obj->u.a.cap; i++)
obj->u.a.items[i] = nil;
- obj->u.a.cap = newcap;
}
obj->u.a.items[obj->u.a.len] = fz_keepobj(item);
obj->u.a.len++;
diff --git a/fitz/obj_dict.c b/fitz/obj_dict.c
index 1742df92..6849b21b 100644
--- a/fitz/obj_dict.c
+++ b/fitz/obj_dict.c
@@ -200,14 +200,13 @@ fz_dictput(fz_obj *obj, fz_obj *key, fz_obj *val)
if (obj->u.d.len + 1 > obj->u.d.cap)
{
- int newcap = obj->u.d.cap * 2;
- obj->u.d.items = fz_realloc(obj->u.d.items, sizeof(fz_keyval) * newcap);
- for (i = obj->u.d.cap; i < newcap; i++)
+ obj->u.d.cap = (obj->u.d.cap * 3) / 2;
+ obj->u.d.items = fz_realloc(obj->u.d.items, sizeof(fz_keyval) * obj->u.d.cap);
+ for (i = obj->u.d.len; i < obj->u.d.cap; i++)
{
obj->u.d.items[i].k = nil;
obj->u.d.items[i].v = nil;
}
- obj->u.d.cap = newcap;
}
/* borked! */
diff --git a/fitz/obj_print.c b/fitz/obj_print.c
index fa582496..ad5bb344 100644
--- a/fitz/obj_print.c
+++ b/fitz/obj_print.c
@@ -325,8 +325,6 @@ fz_fprintobj(FILE *fp, fz_obj *obj, int tight)
else
{
ptr = fz_malloc(n + 1);
- if (!ptr)
- return -1;
fz_sprintobj(ptr, n + 1, obj, tight);
fputs(ptr, fp);
fputc('\n', fp);
diff --git a/fitz/res_font.c b/fitz/res_font.c
index a3ac32a5..4cf523f1 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -13,9 +13,6 @@ fz_newfont(void)
fz_font *font;
font = fz_malloc(sizeof(fz_font));
- if (!font)
- return nil;
-
font->refs = 1;
strcpy(font->name, "<unknown>");
@@ -336,42 +333,25 @@ fz_renderftglyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm)
* Type 3 fonts...
*/
-fz_error
-fz_newtype3font(fz_font **fontp, char *name, fz_matrix matrix)
+fz_font *
+fz_newtype3font(char *name, fz_matrix matrix)
{
fz_font *font;
int i;
font = fz_newfont();
- if (!font)
- return fz_rethrow(-1, "out of memory: font struct");
-
font->t3procs = fz_malloc(sizeof(fz_tree*) * 256);
- if (!font->t3procs)
- {
- fz_free(font);
- return fz_rethrow(-1, "out of memory: type3 font charproc array");
- }
-
font->t3widths = fz_malloc(sizeof(float) * 256);
- if (!font->t3widths)
- {
- fz_free(font->t3procs);
- fz_free(font);
- return fz_rethrow(-1, "out of memory: type3 font widths array");
- }
+ strlcpy(font->name, name, sizeof(font->name));
font->t3matrix = matrix;
for (i = 0; i < 256; i++)
{
font->t3procs[i] = nil;
font->t3widths[i] = 0;
}
-
- strlcpy(font->name, name, sizeof(font->name));
-
- *fontp = font;
- return fz_okay;
+
+ return font;
}
/* XXX UGLY HACK XXX */
diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c
index 024dbea9..23bbf635 100644
--- a/fitz/stm_buffer.c
+++ b/fitz/stm_buffer.c
@@ -56,8 +56,6 @@ fz_dropbuffer(fz_buffer *buf)
void
fz_growbuffer(fz_buffer *buf)
{
- unsigned char *newbp;
-
int rp = buf->rp - buf->bp;
int wp = buf->wp - buf->bp;
int ep = buf->ep - buf->bp;
@@ -68,8 +66,7 @@ fz_growbuffer(fz_buffer *buf)
return;
}
- newbp = fz_realloc(buf->bp, ep * 2);
- buf->bp = newbp;
+ buf->bp = fz_realloc(buf->bp, (ep * 3) / 2);
buf->rp = buf->bp + rp;
buf->wp = buf->bp + wp;
buf->ep = buf->bp + ep * 2;