summaryrefslogtreecommitdiff
path: root/fitz/base_object.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2011-09-18 14:44:01 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-09-20 22:34:25 +0200
commit4fd20cb9e212cde89e2cf53c6d4d121f1d600351 (patch)
tree3184ba27731eb53e83012fbd7cb22cf79a755b8e /fitz/base_object.c
parent02e2e9b427345da8be8e5fd2eccd7deba96593b4 (diff)
downloadmupdf-4fd20cb9e212cde89e2cf53c6d4d121f1d600351.tar.xz
Return expected location when finding keys in dicts.
Diffstat (limited to 'fitz/base_object.c')
-rw-r--r--fitz/base_object.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fitz/base_object.c b/fitz/base_object.c
index 9c6ccfdd..41fe70a5 100644
--- a/fitz/base_object.c
+++ b/fitz/base_object.c
@@ -599,7 +599,7 @@ fz_dict_get_val(fz_obj *obj, int i)
}
static int
-fz_dict_finds(fz_obj *obj, char *key)
+fz_dict_finds(fz_obj *obj, char *key, int *location)
{
if (obj->u.d.sorted)
{
@@ -615,6 +615,9 @@ fz_dict_finds(fz_obj *obj, char *key)
l = m + 1;
else
return m;
+
+ if (location)
+ *location = l;
}
}
@@ -624,6 +627,9 @@ fz_dict_finds(fz_obj *obj, char *key)
for (i = 0; i < obj->u.d.len; i++)
if (strcmp(fz_to_name(obj->u.d.items[i].k), key) == 0)
return i;
+
+ if (location)
+ *location = obj->u.d.len;
}
return -1;
@@ -639,7 +645,7 @@ fz_dict_gets(fz_obj *obj, char *key)
if (!fz_is_dict(obj))
return NULL;
- i = fz_dict_finds(obj, key);
+ i = fz_dict_finds(obj, key, NULL);
if (i >= 0)
return obj->u.d.items[i].v;
@@ -692,7 +698,7 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
return;
}
- i = fz_dict_finds(obj, s);
+ i = fz_dict_finds(obj, s, NULL);
if (i >= 0)
{
fz_drop_obj(obj->u.d.items[i].v);
@@ -730,7 +736,7 @@ fz_dict_dels(fz_obj *obj, char *key)
fz_warn("assert: not a dict (%s)", fz_objkindstr(obj));
else
{
- int i = fz_dict_finds(obj, key);
+ int i = fz_dict_finds(obj, key, NULL);
if (i >= 0)
{
fz_drop_obj(obj->u.d.items[i].k);