diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-03-13 20:25:38 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-03-13 20:59:19 +0000 |
commit | 3212863288c4ad6396482b8fdb14db2af27c123f (patch) | |
tree | 9d7c7efe3a585c538f6e8d0edd5e3a77b5b8b6b5 /pdf/pdf_store.c | |
parent | b6e9b2f8fe172d7175cea3d14d89f986688639af (diff) | |
parent | 33dc06b61c0816854193f006c35a9e797f098a22 (diff) | |
download | mupdf-3212863288c4ad6396482b8fdb14db2af27c123f.tar.xz |
Merge master and pg_android branches
Bring up to date with current APIs, including text device changes.
Diffstat (limited to 'pdf/pdf_store.c')
-rw-r--r-- | pdf/pdf_store.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c new file mode 100644 index 00000000..2a3b8b07 --- /dev/null +++ b/pdf/pdf_store.c @@ -0,0 +1,74 @@ +#include "fitz-internal.h" +#include "mupdf-internal.h" + +static int +pdf_make_hash_key(fz_store_hash *hash, void *key_) +{ + pdf_obj *key = (pdf_obj *)key_; + + if (!pdf_is_indirect(key)) + return 0; + hash->u.i.i0 = pdf_to_num(key); + hash->u.i.i1 = pdf_to_gen(key); + return 1; +} + +static void * +pdf_keep_key(fz_context *ctx, void *key) +{ + return (void *)pdf_keep_obj((pdf_obj *)key); +} + +static void +pdf_drop_key(fz_context *ctx, void *key) +{ + pdf_drop_obj((pdf_obj *)key); +} + +static int +pdf_cmp_key(void *k0, void *k1) +{ + return pdf_objcmp((pdf_obj *)k0, (pdf_obj *)k1); +} + +static void +pdf_debug_key(void *key_) +{ + pdf_obj *key = (pdf_obj *)key_; + + if (pdf_is_indirect(key)) + { + printf("(%d %d R) ", pdf_to_num(key), pdf_to_gen(key)); + } else + pdf_print_obj(key); +} + +static fz_store_type pdf_obj_store_type = +{ + pdf_make_hash_key, + pdf_keep_key, + pdf_drop_key, + pdf_cmp_key, + pdf_debug_key +}; + +void +pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize) +{ + void *existing; + existing = fz_store_item(ctx, key, val, itemsize, &pdf_obj_store_type); + assert(existing == NULL); +} + +void * +pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) +{ + return fz_find_item(ctx, free, key, &pdf_obj_store_type); +} + +void +pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) +{ + fz_remove_item(ctx, free, key, &pdf_obj_store_type); +} + |