/* 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