]>
git.saurik.com Git - apple/libc.git/blob - include/objc/zone.h
94dd796500f15069339290a12133f92e08b19a18
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #import <objc/malloc.h>
25 typedef malloc_zone_t NXZone
;
27 #define NX_NOZONE ((NXZone *)0)
29 /********* Interface to zone based malloc ************/
31 extern NXZone
*NXDefaultMallocZone(void);
32 // Returns the default zone used by the malloc(3) calls
34 extern NXZone
*NXCreateZone(size_t startSize
, size_t granularity
, int canFree
);
35 // Create a new zone with its own memory pool.
36 // canfree: if 0 the allocator will never free memory and mallocing will be fast
38 extern void NXNameZone(NXZone
*z
, const char *name
);
39 // name a zone; The string will be copied
41 extern void *NXZoneMalloc(malloc_zone_t
*zone
, size_t size
);
43 extern void *NXZoneRealloc(malloc_zone_t
*zone
, void *ptr
, size_t size
);
45 extern void *NXZoneCalloc(NXZone
*zonep
, size_t numElems
, size_t byteSize
);
46 // Allocates and then clears
48 extern void NXZoneFree(malloc_zone_t
*zone
, void *ptr
);
50 extern void NXDestroyZone(malloc_zone_t
*zone
);
52 extern NXZone
*NXZoneFromPtr(void *ptr
);
53 // Returns the zone for a pointer, or NX_NOZONE if not in any zone.
54 // The ptr must have been returned from a malloc or realloc call.