rev 381 - trunk
[email protected] Mon, 3 Jan 2005 16:53:10 -0800 (PST)
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: giles
Date: 2005-01-03 16:53:10 -0800 (Mon, 03 Jan 2005)
New Revision: 381
Modified:
trunk/jbig2_arith.c
trunk/jbig2_generic.c
trunk/jbig2_refinement.c
Log:
Properly free arithmetic coding and word stream states after region
decode. Also use the allocator defined in the library context instead
of raw malloc for the arith state.
Modified: trunk/jbig2_arith.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_arith.c 2005-01-04 00:34:16 UTC (rev 380)
+++ trunk/jbig2_arith.c 2005-01-04 00:53:10 UTC (rev 381)
@@ -1,7 +1,7 @@
/*
jbig2dec
=20
- Copyright (c) 2001 artofcode LLC.
+ Copyright (c) 2001-2005 artofcode LLC.
=20
This software is provided AS-IS with no warranty,
either express or implied.
@@ -174,11 +174,18 @@
}
#endif
=20
+/** Allocate and initialize a new arithmetic coding state
+ * the returned pointer can simply be freed; this does
+ * not affect the associated Jbig2WordStream.
+ */
Jbig2ArithState *
jbig2_arith_new (Jbig2Ctx *ctx, Jbig2WordStream *ws)
{
- Jbig2ArithState *result =3D (Jbig2ArithState *)malloc (sizeof(Jbig2Ari=
thState));
+ Jbig2ArithState *result;
=20
+ result =3D (Jbig2ArithState *)jbig2_alloc(ctx->allocator,
+ sizeof(Jbig2ArithState));
+
result->ws =3D ws;
=20
result->next_word =3D ws->get_next_word (ws, 0);
Modified: trunk/jbig2_generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_generic.c 2005-01-04 00:34:16 UTC (rev 380)
+++ trunk/jbig2_generic.c 2005-01-04 00:53:10 UTC (rev 381)
@@ -611,16 +611,17 @@
as =3D jbig2_arith_new(ctx, ws);
code =3D jbig2_decode_generic_region(ctx, segment, ¶ms,
as, image, GB_stats);
+ jbig2_free(ctx->allocator, as);
+ jbig2_word_stream_buf_free(ctx, ws);
+
+ jbig2_free(ctx->allocator, GB_stats);
}
=20
- /* todo: free ws, as */
- =20
+
jbig2_image_compose(ctx, ctx->pages[ctx->current_page].image, image,
rsi.x, rsi.y, JBIG2_COMPOSE_OR);
jbig2_image_release(ctx, image);
=20
- jbig2_free(ctx->allocator, GB_stats);
-
return code;
}
=20
Modified: trunk/jbig2_refinement.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_refinement.c 2005-01-04 00:34:16 UTC (rev 380)
+++ trunk/jbig2_refinement.c 2005-01-04 00:53:10 UTC (rev 381)
@@ -423,7 +423,8 @@
code =3D jbig2_decode_refinement_region(ctx, segment, ¶ms,
as, image, GR_stats);
=20
- /* TODO: free ws, as */
+ jbig2_free(ctx->allocator, as);
+ jbig2_word_stream_buf_free(ctx, ws);
jbig2_free(ctx->allocator, GR_stats);
=20
if ((segment->flags & 63) =3D=3D 40) {