summaryrefslogtreecommitdiff
path: root/object
diff options
context:
space:
mode:
Diffstat (limited to 'object')
-rw-r--r--object/array.c16
-rw-r--r--object/dict.c16
-rw-r--r--object/parse.c6
-rw-r--r--object/simple.c7
4 files changed, 26 insertions, 19 deletions
diff --git a/object/array.c b/object/array.c
index d7beeb38..c57f3952 100644
--- a/object/array.c
+++ b/object/array.c
@@ -1,5 +1,7 @@
#include <fitz.h>
+void fz_droparray(fz_obj *obj);
+
fz_error *
fz_newarray(fz_obj **op, int initialcap)
{
@@ -40,7 +42,7 @@ fz_copyarray(fz_obj **op, fz_obj *obj)
for (i = 0; i < fz_arraylen(obj); i++) {
err = fz_arraypush(new, fz_arrayget(obj, i));
- if (err) { fz_freearray(new); return err; }
+ if (err) { fz_droparray(new); return err; }
}
return nil;
@@ -67,23 +69,23 @@ fz_deepcopyarray(fz_obj **op, fz_obj *obj)
if (fz_isarray(val)) {
err = fz_deepcopyarray(&val, val);
- if (err) { fz_freearray(new); return err; }
+ if (err) { fz_droparray(new); return err; }
err = fz_arraypush(new, val);
- if (err) { fz_dropobj(val); fz_freearray(new); return err; }
+ if (err) { fz_dropobj(val); fz_droparray(new); return err; }
fz_dropobj(val);
}
else if (fz_isdict(val)) {
err = fz_deepcopydict(&val, val);
- if (err) { fz_freearray(new); return err; }
+ if (err) { fz_droparray(new); return err; }
err = fz_arraypush(new, val);
- if (err) { fz_dropobj(val); fz_freearray(new); return err; }
+ if (err) { fz_dropobj(val); fz_droparray(new); return err; }
fz_dropobj(val);
}
else {
err = fz_arraypush(new, val);
- if (err) { fz_freearray(new); return err; }
+ if (err) { fz_droparray(new); return err; }
}
}
@@ -166,7 +168,7 @@ fz_arraypush(fz_obj *obj, fz_obj *item)
}
void
-fz_freearray(fz_obj *obj)
+fz_droparray(fz_obj *obj)
{
int i;
diff --git a/object/dict.c b/object/dict.c
index fd2f3382..61e55bc4 100644
--- a/object/dict.c
+++ b/object/dict.c
@@ -1,5 +1,7 @@
#include <fitz.h>
+void fz_dropdict(fz_obj *obj);
+
fz_error *
fz_newdict(fz_obj **op, int initialcap)
{
@@ -42,7 +44,7 @@ fz_copydict(fz_obj **op, fz_obj *obj)
for (i = 0; i < fz_dictlen(obj); i++) {
err = fz_dictput(new, fz_dictgetkey(obj, i), fz_dictgetval(obj, i));
- if (err) { fz_freedict(new); return err; }
+ if (err) { fz_dropdict(new); return err; }
}
return nil;
@@ -69,23 +71,23 @@ fz_deepcopydict(fz_obj **op, fz_obj *obj)
if (fz_isarray(val)) {
err = fz_deepcopyarray(&val, val);
- if (err) { fz_freedict(new); return err; }
+ if (err) { fz_dropdict(new); return err; }
err = fz_dictput(new, fz_dictgetkey(obj, i), val);
- if (err) { fz_dropobj(val); fz_freedict(new); return err; }
+ if (err) { fz_dropobj(val); fz_dropdict(new); return err; }
fz_dropobj(val);
}
else if (fz_isdict(val)) {
err = fz_deepcopydict(&val, val);
- if (err) { fz_freedict(new); return err; }
+ if (err) { fz_dropdict(new); return err; }
err = fz_dictput(new, fz_dictgetkey(obj, i), val);
- if (err) { fz_dropobj(val); fz_freedict(new); return err; }
+ if (err) { fz_dropobj(val); fz_dropdict(new); return err; }
fz_dropobj(val);
}
else {
err = fz_dictput(new, fz_dictgetkey(obj, i), val);
- if (err) { fz_freedict(new); return err; }
+ if (err) { fz_dropdict(new); return err; }
}
}
@@ -240,7 +242,7 @@ fz_dictdel(fz_obj *obj, fz_obj *key)
}
void
-fz_freedict(fz_obj *obj)
+fz_dropdict(fz_obj *obj)
{
int i;
diff --git a/object/parse.c b/object/parse.c
index c065a132..99211243 100644
--- a/object/parse.c
+++ b/object/parse.c
@@ -151,7 +151,7 @@ static fz_error *parsedict(fz_obj **obj, char **sp, struct vap *v)
error:
if (val) fz_dropobj(val);
if (key) fz_dropobj(key);
- if (dict) fz_freedict(dict);
+ if (dict) fz_dropobj(dict);
*obj = nil;
*sp = s;
return err;
@@ -180,10 +180,10 @@ static fz_error *parsearray(fz_obj **obj, char **sp, struct vap *v)
}
err = parseobj(&o, &s, v);
- if (err) { *obj = nil; fz_freearray(a); return err; }
+ if (err) { *obj = nil; fz_dropobj(a); return err; }
err = fz_arraypush(a, o);
- if (err) { fz_dropobj(o); *obj = nil; fz_freearray(a); return err; }
+ if (err) { fz_dropobj(o); *obj = nil; fz_dropobj(a); return err; }
fz_dropobj(o);
}
diff --git a/object/simple.c b/object/simple.c
index bee7cf46..953dcfa7 100644
--- a/object/simple.c
+++ b/object/simple.c
@@ -1,5 +1,8 @@
#include <fitz.h>
+extern void fz_droparray(fz_obj *array);
+extern void fz_dropdict(fz_obj *dict);
+
#define NEWOBJ(KIND,SIZE) \
fz_obj *o; \
o = *op = fz_malloc(SIZE); \
@@ -85,9 +88,9 @@ fz_dropobj(fz_obj *o)
o->refcount --;
if (o->refcount == 0) {
if (o->kind == FZ_ARRAY)
- fz_freearray(o);
+ fz_droparray(o);
else if (o->kind == FZ_DICT)
- fz_freedict(o);
+ fz_dropdict(o);
else
fz_free(o);
}