]>
git.saurik.com Git - apple/libc.git/blob - include/objc/zone.h
dad101291e0967dba99966b00e144fdb40b65d2d
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #import <malloc/malloc.h>
31 typedef malloc_zone_t NXZone
;
33 #define NX_NOZONE ((NXZone *)0)
35 /********* Interface to zone based malloc ************/
37 #include <sys/cdefs.h>
40 extern NXZone
*NXDefaultMallocZone(void);
41 // Returns the default zone used by the malloc(3) calls
43 extern NXZone
*NXCreateZone(size_t startSize
, size_t granularity
, int canFree
);
44 // Create a new zone with its own memory pool.
45 // canfree: if 0 the allocator will never free memory and mallocing will be fast
47 extern void NXNameZone(NXZone
*z
, const char *name
);
48 // name a zone; The string will be copied
50 extern void *NXZoneMalloc(malloc_zone_t
*zone
, size_t size
);
52 extern void *NXZoneRealloc(malloc_zone_t
*zone
, void *ptr
, size_t size
);
54 extern void *NXZoneCalloc(NXZone
*zonep
, size_t numElems
, size_t byteSize
);
55 // Allocates and then clears
57 extern void NXZoneFree(malloc_zone_t
*zone
, void *ptr
);
59 extern void NXDestroyZone(malloc_zone_t
*zone
);
61 extern NXZone
*NXZoneFromPtr(void *ptr
);
62 // Returns the zone for a pointer, or NX_NOZONE if not in any zone.
63 // The ptr must have been returned from a malloc or realloc call.
66 #endif /* _OBJC_ZONE_H_ */