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