summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-08-17 15:03:43 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-08-24 14:09:06 +0200
commitd88fc90e806a72f90667ec780f3370794cbc0c42 (patch)
tree4197758cf043c96a427dffb90895e4dbd6281044 /source/pdf
parent7bb57105fad01e11c251f3b464d2719df2632c08 (diff)
downloadmupdf-d88fc90e806a72f90667ec780f3370794cbc0c42.tar.xz
Add pdf_array_find to look up the index of an object in an array.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-object.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 8fcbceda..10eb6690 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -808,6 +808,19 @@ pdf_array_contains(fz_context *ctx, pdf_obj *arr, pdf_obj *obj)
return 0;
}
+int
+pdf_array_find(fz_context *ctx, pdf_obj *arr, pdf_obj *obj)
+{
+ int i, len;
+
+ len = pdf_array_len(ctx, arr);
+ for (i = 0; i < len; i++)
+ if (!pdf_objcmp(ctx, pdf_array_get(ctx, arr, i), obj))
+ return i;
+
+ return -1;
+}
+
pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, const fz_rect *rect)
{
pdf_obj *arr = NULL;