/* begincopyright
  Copyright (c) 1988 Xerox Corporation. All rights reserved.
  Use and copying of this software and preparation of derivative works based
  upon this software are permitted. Any distribution of this software or
  derivative works must comply with all applicable United States export
  control laws. This software is made available AS IS, and Xerox Corporation
  makes no warranty about the software, its performance or its conformity to
  any specification. Any person obtaining a copy of this software is requested
  to send their name and post office or electronic mail address to:
    PCR Coordinator
    Xerox PARC
    3333 Coyote Hill Rd.
    Palo Alto, CA 94304
  endcopyright */

/*
 * PZone.h
 *
 * Demers, July 24, 1989 10:17:37 am PDT
 *
 * Simple Zones for "Permanent" or "Pascal-like" applications.
 *
 * Most operations correspond to those in the standard malloc/free/...
 *   package, and default to those if the zone argument is NIL.
 *
 * PZones give better reference locality than the standard package.
 *
 * They also support a stack-like free: free everything allocated after
 *   a remembered time.
 *
 */

#ifndef ←XR←PZONE←
#define ←XR←PZONE← 1

#ifndef ←XR←BASIC←TYPES←
#include "xr/BasicTypes.h"
#endif


typedef char * XR←PZone;	/* opaque */

extern XR←PZone
XR←PZCreate(/* bool ptrFree, unsigned growBytes */);
/*
    Create a zone.
	Parameter ptrFree controls whether garbage collector traces thru zone.
	Parameter growBytes is amount by which zone is grown when necessary.
*/

extern char *
XR←PZmalloc(/* XR←PZone z, unsigned bytes */);

extern void
XR←PZfree(/* XR←PZone z, char *ptr */);

extern char *
XR←PZcalloc(/* XR←PZone z, unsigned bytes */);

extern void
XR←PZcfree(/* XR←PZone z, char *ptr */);

extern char *
XR←PZremember(/* XR←PZone z */);
/*
    Return a "magic cookie" for use in XR←PZrevert.
*/

extern void
XR←PZrevert(/* XR←PZone z, char *cookie */);
/*
    Free everything allocated in zone since the cookie was created.
    Special cases:
        cookie == XR←PZ←FREE←NOTHING (== NIL) ==> free nothing
        cookie == XR←PZ←FREE←ALL (== (char *)(1)) ==> free everything in z
    Behavior with other cookies is unpredictable.
*/

#define XR←PZ←FREE←NOTHING NIL
#define XR←PZ←FREE←ALL ((char *)(1))

#endif