summaryrefslogtreecommitdiff
path: root/base
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 /base
parent2ec725624d637789845478a90f799e9eeb54f9ee (diff)
downloadmupdf-58de1fff510078e3d2d8cfce033c87299adf78f0.tar.xz
filter reference counting
Diffstat (limited to 'base')
-rw-r--r--base/error.c8
-rw-r--r--base/memory.c4
2 files changed, 8 insertions, 4 deletions
diff --git a/base/error.c b/base/error.c
index df795192..489dcc40 100644
--- a/base/error.c
+++ b/base/error.c
@@ -20,9 +20,10 @@ fz_throwMS(char *fmt, ...)
eo = fz_malloc(sizeof(fz_error));
if (!eo) return fz_outofmem;
+ eo->nrefs = 1;
strlcpy(eo->func, "unknown", sizeof eo->func);
strlcpy(eo->file, "unknown", sizeof eo->file);
- eo->line = -1;
+ eo->line = 0;
va_start(ap, fmt);
vsnprintf(eo->msg, sizeof eo->msg, fmt, ap);
@@ -41,6 +42,7 @@ fz_throw0(const char *func, const char *file, int line, char *fmt, ...)
eo = fz_malloc(sizeof(fz_error));
if (!eo) return fz_outofmem;
+ eo->nrefs = 1;
strlcpy(eo->func, func, sizeof eo->func);
strlcpy(eo->file, file, sizeof eo->file);
eo->line = line;
@@ -59,7 +61,9 @@ fz_throw0(const char *func, const char *file, int line, char *fmt, ...)
void
fz_droperror(fz_error *eo)
{
- if (!eo->frozen)
+ if (eo->nrefs > 0)
+ eo->nrefs--;
+ if (eo->nrefs == 0)
fz_free(eo);
}
diff --git a/base/memory.c b/base/memory.c
index b0858383..2c2f8e0d 100644
--- a/base/memory.c
+++ b/base/memory.c
@@ -39,11 +39,11 @@ static fz_memorycontext defmem = { stdmalloc, stdrealloc, stdfree };
static fz_memorycontext *curmem = &defmem;
fz_error fz_koutofmem = {
+ -1,
{"out of memory"},
{"<malloc>"},
{"memory.c"},
- 0,
- 1
+ 0
};
fz_memorycontext *