summaryrefslogtreecommitdiff
path: root/filter/filter.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-11-11 07:15:07 +0100
committerTor Andersson <tor@ghostscript.com>2004-11-11 07:15:07 +0100
commit58de1fff510078e3d2d8cfce033c87299adf78f0 (patch)
tree80635049b0d1ccc8840717982afe983ea18c0b37 /filter/filter.c
parent2ec725624d637789845478a90f799e9eeb54f9ee (diff)
downloadmupdf-58de1fff510078e3d2d8cfce033c87299adf78f0.tar.xz
filter reference counting
Diffstat (limited to 'filter/filter.c')
-rw-r--r--filter/filter.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 25bbd441..4bd8c4ff 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -1,8 +1,8 @@
#include <fitz.h>
-fz_error fz_kioneedin = { "<ioneedin>", "<process>", "filter.c", 0, 1 };
-fz_error fz_kioneedout = { "<ioneedout>", "<process>", "filter.c", 0, 1 };
-fz_error fz_kiodone = { "<iodone>", "<process>", "filter.c", 0, 1 };
+fz_error fz_kioneedin = { -1, "<ioneedin>", "<process>", "filter.c", 0 };
+fz_error fz_kioneedout = { -1, "<ioneedout>", "<process>", "filter.c", 0 };
+fz_error fz_kiodone = { -1, "<iodone>", "<process>", "filter.c", 0 };
fz_error *
fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out)
@@ -31,11 +31,21 @@ fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out)
return reason;
}
+fz_filter *
+fz_keepfilter(fz_filter *f)
+{
+ f->nrefs ++;
+ return f;
+}
+
void
fz_dropfilter(fz_filter *f)
{
- if (f->drop)
- f->drop(f);
- fz_free(f);
+ if (--f->nrefs == 0)
+ {
+ if (f->drop)
+ f->drop(f);
+ fz_free(f);
+ }
}