2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
33 static pthread_mutex_t _zone_mutex
= PTHREAD_MUTEX_INITIALIZER
;
36 nXDefaultMallocZone
= 0,
49 static char *once
[] = {
50 "NXDefaultMallocZone",
64 extern int __is_threaded
;
66 /********* NX functions ************/
69 _deprecated(int index
)
72 pthread_mutex_lock(&_zone_mutex
);
74 fprintf(stderr
, "*** %s[%d]: %s() is deprecated and will be removed in the future\n", getprogname(), getpid(), once
[index
]);
78 pthread_mutex_unlock(&_zone_mutex
);
81 malloc_zone_t
*NXDefaultMallocZone() {
82 _deprecated(nXDefaultMallocZone
);
83 return malloc_default_zone();
86 malloc_zone_t
*NXCreateZone(size_t startsize
, size_t granularity
, int canfree
) {
87 _deprecated(nXCreateZone
);
88 return malloc_create_zone(startsize
, 0);
91 void NXNameZone(malloc_zone_t
*z
, const char *name
) {
92 _deprecated(nXNameZone
);
93 malloc_set_zone_name(z
, name
);
96 void *NXZoneMalloc(malloc_zone_t
*zone
, size_t size
) {
97 _deprecated(nXZoneMalloc
);
98 return malloc_zone_malloc(zone
, size
);
101 void *NXZoneRealloc(malloc_zone_t
*zone
, void *ptr
, size_t size
) {
102 _deprecated(nXZoneRealloc
);
103 return malloc_zone_realloc(zone
, ptr
, size
);
106 void *NXZoneCalloc(malloc_zone_t
*zone
, size_t num_items
, size_t size
) {
107 _deprecated(nXZoneCalloc
);
108 return malloc_zone_calloc(zone
, num_items
, size
);
111 void NXZoneFree(malloc_zone_t
*zone
, void *ptr
) {
112 _deprecated(nXZoneFromPtr
);
113 malloc_zone_free(zone
, ptr
);
116 void NXDestroyZone(malloc_zone_t
*zone
) {
117 _deprecated(nXDestroyZone
);
118 if (zone
== malloc_default_zone()) return; // we avoid destroying child zones
119 malloc_destroy_zone(zone
);
122 NXZone
*NXZoneFromPtr(void *ptr
) {
123 NXZone
*zone
= malloc_zone_from_ptr(ptr
);
124 _deprecated(nXZoneFromPtr
);
126 malloc_printf("*** NXZoneFromPtr() did not find any zone for %p; returning default\n", ptr
);
133 void NXAddRegion(void *start
, size_t size
, malloc_zone_t
*zone
) {
134 malloc_printf("*** OBSOLETE: NXAddRegion()\n");
137 void NXRemoveRegion(void *start
) {
138 malloc_printf("*** OBSOLETE: NXRemoveRegion()\n");
140 #endif /* OBSOLETED */
142 void NXZonePtrInfo(void *ptr
) {
143 _deprecated(nXZonePtrInfo
);
144 malloc_zone_print_ptr_info(ptr
);
147 int NXMallocCheck(void) {
148 _deprecated(nXMallocCheck
);
149 malloc_zone_check(NULL
);
153 void _NXMallocDumpZones(void) {
154 _deprecated(_nXMallocDumpZones
);
155 malloc_zone_print(NULL
, 0);
158 /***************** UNIMPLEMENTED ENTRY POINTS ********************/
161 void NXMergeZone(malloc_zone_t
*z
) {
162 static char warned
= 0;
164 malloc_printf("*** NXMergeZone() now obsolete, does nothing\n");
169 boolean_t
NXProtectZone(malloc_zone_t
*zone
, int protection
) {
170 malloc_printf("*** NXProtectZone() is obsolete\n");
174 malloc_zone_t
*NXCreateChildZone(malloc_zone_t
*parentzone
, size_t startsize
, size_t granularity
, int canfree
) {
175 // We can not remove this one as it is still used by IndexingKit
176 static char warned
= 0;
178 malloc_printf("*** NXCreateChildZone() now obsolete, has been defined to create new zone\n");
181 return NXCreateZone(startsize
, granularity
, canfree
);
184 void _NXMallocDumpFrees(void) {
185 malloc_printf("*** OBSOLETE: _NXMallocDumpFrees()\n");
187 #endif /* OBSOLETED */