szlibxx.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright (C) 1998 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: szlibxx.h,v 1.2 2000/09/19 19:00:51 lpd Exp $ */
  16. /* Implementation definitions for zlib interface */
  17. /* Must be compiled with -I$(ZSRCDIR) */
  18. #ifndef szlibxx_INCLUDED
  19. # define szlibxx_INCLUDED
  20. #include "szlibx.h"
  21. #include "zlib.h"
  22. /*
  23. * We don't want to allocate zlib's private data directly from
  24. * the C heap, but we must allocate it as immovable; and to avoid
  25. * garbage collection issues, we must keep GC-traceable pointers
  26. * to every block allocated. Since the stream state itself is movable,
  27. * we have to allocate an immovable block for the z_stream state as well.
  28. */
  29. typedef struct zlib_block_s zlib_block_t;
  30. struct zlib_block_s {
  31. void *data;
  32. zlib_block_t *next;
  33. zlib_block_t *prev;
  34. };
  35. #define private_st_zlib_block() /* in szlibc.c */\
  36. gs_private_st_ptrs3(st_zlib_block, zlib_block_t, "zlib_block_t",\
  37. zlib_block_enum_ptrs, zlib_block_reloc_ptrs, next, prev, data)
  38. /* The typedef is in szlibx.h */
  39. /*typedef*/ struct zlib_dynamic_state_s {
  40. gs_memory_t *memory;
  41. zlib_block_t *blocks;
  42. z_stream zstate;
  43. } /*zlib_dynamic_state_t*/;
  44. #define private_st_zlib_dynamic_state() /* in szlibc.c */\
  45. gs_private_st_ptrs1(st_zlib_dynamic_state, zlib_dynamic_state_t,\
  46. "zlib_dynamic_state_t", zlib_dynamic_enum_ptrs, zlib_dynamic_reloc_ptrs,\
  47. blocks)
  48. /*
  49. * Provide zlib-compatible allocation and freeing functions.
  50. * The mem pointer actually points to the dynamic state.
  51. */
  52. void *s_zlib_alloc(P3(void *mem, uint items, uint size));
  53. void s_zlib_free(P2(void *mem, void *address));
  54. /* Internal procedure to allocate and free the dynamic state. */
  55. int s_zlib_alloc_dynamic_state(P1(stream_zlib_state *ss));
  56. void s_zlib_free_dynamic_state(P1(stream_zlib_state *ss));
  57. #endif /* szlibxx_INCLUDED */