]>
git.saurik.com Git - apple/libc.git/blob - gen/zone.c
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@
30 /********* NX functions ************/
32 malloc_zone_t
*NXDefaultMallocZone() {
33 return malloc_default_zone();
36 malloc_zone_t
*NXCreateZone(size_t startsize
, size_t granularity
, int canfree
) {
37 return malloc_create_zone(startsize
, 0);
40 void NXNameZone(malloc_zone_t
*z
, const char *name
) {
41 malloc_set_zone_name(z
, name
);
44 void *NXZoneMalloc(malloc_zone_t
*zone
, size_t size
) {
45 return malloc_zone_malloc(zone
, size
);
48 void *NXZoneRealloc(malloc_zone_t
*zone
, void *ptr
, size_t size
) {
49 return malloc_zone_realloc(zone
, ptr
, size
);
52 void *NXZoneCalloc(malloc_zone_t
*zone
, size_t num_items
, size_t size
) {
53 return malloc_zone_calloc(zone
, num_items
, size
);
56 void NXZoneFree(malloc_zone_t
*zone
, void *ptr
) {
57 malloc_zone_free(zone
, ptr
);
60 void NXDestroyZone(malloc_zone_t
*zone
) {
61 if (zone
== malloc_default_zone()) return; // we avoid destroying child zones
62 malloc_destroy_zone(zone
);
65 NXZone
*NXZoneFromPtr(void *ptr
) {
66 NXZone
*zone
= malloc_zone_from_ptr(ptr
);
68 fprintf(stderr
, "*** malloc[%d]: NXZoneFromPtr() did not find any zone for %p; returning default\n", getpid(), ptr
);
74 void NXAddRegion(void *start
, size_t size
, malloc_zone_t
*zone
) {
75 fprintf(stderr
, "*** malloc[%d]: OBSOLETE: NXAddRegion()\n", getpid());
78 void NXRemoveRegion(void *start
) {
79 fprintf(stderr
, "*** malloc[%d]: OBSOLETE: NXRemoveRegion()\n", getpid());
82 void NXZonePtrInfo(void *ptr
) {
83 malloc_zone_print_ptr_info(ptr
);
86 int NXMallocCheck(void) {
87 malloc_zone_check(NULL
);
91 void _NXMallocDumpZones(void) {
92 malloc_zone_print(NULL
, 0);
95 /***************** UNIMPLEMENTED ENTRY POINTS ********************/
97 void NXMergeZone(malloc_zone_t
*z
) {
98 static char warned
= 0;
100 fprintf(stderr
, "*** malloc[%d]: NXMergeZone() now obsolete, does nothing\n", getpid());
105 boolean_t
NXProtectZone(malloc_zone_t
*zone
, int protection
) {
106 fprintf(stderr
, "*** malloc[%d]: NXProtectZone() is obsolete\n", getpid());
110 malloc_zone_t
*NXCreateChildZone(malloc_zone_t
*parentzone
, size_t startsize
, size_t granularity
, int canfree
) {
111 // We can not remove this one as it is still used by IndexingKit
112 static char warned
= 0;
114 fprintf(stderr
, "*** malloc[%d]: NXCreateChildZone() now obsolete, has been defined to create new zone\n", getpid());
117 return NXCreateZone(startsize
, granularity
, canfree
);
120 void _NXMallocDumpFrees(void) {
121 fprintf(stderr
, "*** malloc[%d]: OBSOLETE: _NXMallocDumpFrees()\n", getpid());