home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / ISAVE.H < prev    next >
C/C++ Source or Header  |  1994-07-27  |  4KB  |  82 lines

  1. /* Copyright (C) 1991, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* isave.h */
  20. /* Interface to Ghostscript save/restore machinery */
  21. /* Requires imemory.h */
  22.  
  23. /*
  24.  * According to the PostScript language definition, save objects are simple,
  25.  * not composite.  Consequently, we cannot use their natural representation,
  26.  * namely a t_struct pointing to an alloc_save_t, since we aren't willing to
  27.  * allocate them all in global VM and rely on garbage collection to clean
  28.  * them up.  Instead, we assign each one a unique "save ID", and store this
  29.  * in the alloc_save_t object.  Mapping the number to the object requires
  30.  * at most searching the local save chain for the current gs_dual_memory_t,
  31.  * and this approach means we don't have to do anything to invalidate
  32.  * save objects when we do a restore.
  33.  */
  34. typedef struct alloc_save_s alloc_save_t;
  35.  
  36. /* Initialize the save machinery. */
  37. extern void alloc_save_init(P1(gs_dual_memory_t *));
  38.  
  39. /* Map a save ID to its save object.  Return 0 if the ID is invalid. */
  40. alloc_save_t *alloc_find_save(P2(const gs_dual_memory_t *, ulong));
  41.  
  42. /* Save the state.  Return 0 if we can't allocate the save object, */
  43. /* otherwise return the save ID.  The second argument is a client data */
  44. /* pointer, assumed to point to an object. */
  45. ulong alloc_save_state(P2(gs_dual_memory_t *, void *));
  46.  
  47. /* Get the client pointer passed to alloc_saved_state. */
  48. void *alloc_save_client_data(P1(const alloc_save_t *));
  49.  
  50. /* Return the current level of save nesting. */
  51. int alloc_save_level(P1(const gs_dual_memory_t *));
  52.  
  53. /* Check whether a pointer refers to an object allocated since a given save. */
  54. bool alloc_is_since_save(P2(const char *, const alloc_save_t *));
  55.  
  56. /* Check whether a name was created since a given save. */
  57. bool alloc_name_is_since_save(P2(const ref *, const alloc_save_t *));
  58. bool alloc_name_index_is_since_save(P2(uint, const alloc_save_t *));
  59.  
  60. /* Restore the state.  Assume the caller obtained the argument by calling */
  61. /* alloc_find_save; if this is so, the operation cannot fail. */
  62. void alloc_restore_state(P1(alloc_save_t *));
  63.  
  64. /* Release all memory -- like doing a restore "past the bottom". */
  65. void alloc_restore_all(P1(gs_dual_memory_t *));
  66.  
  67. /*
  68.  * If we are in a save, we want to save the old contents if l_new is
  69.  * not set; if we are not in a save, we never want to save old contents.
  70.  * We can test this quickly with a single mask that is l_new if we are
  71.  * in a save, and -1 if we are not, since type_attrs of a valid ref
  72.  * cannot be 0; this is the test_mask in a gs_dual_memory_t.  Similarly,
  73.  * we want to set the l_new bit in newly allocated objects iff we are in
  74.  * a save; this is the new_mask in a gs_dual_memory_t.
  75.  *
  76.  * Note that in order to tell whether the containing object is allocated
  77.  * in global or local VM, we have to pass a pointer to it when saving
  78.  * a change.
  79.  */
  80. int    alloc_save_change(P4(gs_dual_memory_t *, const ref *pcont,
  81.                  ref_packed *ptr, client_name_t cname));
  82.