]> git.saurik.com Git - apple/libc.git/blame - gen/zone.c
Libc-262.3.2.tar.gz
[apple/libc.git] / gen / zone.c
CommitLineData
e9ce8d39
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
734aad71 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
e9ce8d39 7 *
734aad71
A
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
13 * file.
14 *
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
e9ce8d39
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
734aad71
A
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.
e9ce8d39
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#import <objc/zone.h>
27#import <stdio.h>
28#import <libc.h>
29
30/********* NX functions ************/
31
32malloc_zone_t *NXDefaultMallocZone() {
33 return malloc_default_zone();
34}
35
36malloc_zone_t *NXCreateZone(size_t startsize, size_t granularity, int canfree) {
37 return malloc_create_zone(startsize, 0);
38}
39
40void NXNameZone(malloc_zone_t *z, const char *name) {
41 malloc_set_zone_name(z, name);
42}
43
44void *NXZoneMalloc(malloc_zone_t *zone, size_t size) {
45 return malloc_zone_malloc(zone, size);
46}
47
48void *NXZoneRealloc(malloc_zone_t *zone, void *ptr, size_t size) {
49 return malloc_zone_realloc(zone, ptr, size);
50}
51
52void *NXZoneCalloc(malloc_zone_t *zone, size_t num_items, size_t size) {
53 return malloc_zone_calloc(zone, num_items, size);
54}
55
56void NXZoneFree(malloc_zone_t *zone, void *ptr) {
57 malloc_zone_free(zone, ptr);
58}
59
60void NXDestroyZone(malloc_zone_t *zone) {
61 if (zone == malloc_default_zone()) return; // we avoid destroying child zones
62 malloc_destroy_zone(zone);
63}
64
65NXZone *NXZoneFromPtr(void *ptr) {
66 NXZone *zone = malloc_zone_from_ptr(ptr);
67 if (!zone) {
68 fprintf(stderr, "*** malloc[%d]: NXZoneFromPtr() did not find any zone for %p; returning default\n", getpid(), ptr);
69 zone = NX_NOZONE;
70 }
71 return zone;
72}
73
74void NXAddRegion(void *start, size_t size, malloc_zone_t *zone) {
75 fprintf(stderr, "*** malloc[%d]: OBSOLETE: NXAddRegion()\n", getpid());
76}
77
78void NXRemoveRegion(void *start) {
79 fprintf(stderr, "*** malloc[%d]: OBSOLETE: NXRemoveRegion()\n", getpid());
80}
81
82void NXZonePtrInfo(void *ptr) {
83 malloc_zone_print_ptr_info(ptr);
84}
85
86int NXMallocCheck(void) {
87 malloc_zone_check(NULL);
88 return 1;
89}
90
91void _NXMallocDumpZones(void) {
92 malloc_zone_print(NULL, 0);
93}
94
95/***************** UNIMPLEMENTED ENTRY POINTS ********************/
96
97void NXMergeZone(malloc_zone_t *z) {
98 static char warned = 0;
99 if (!warned) {
100 fprintf(stderr, "*** malloc[%d]: NXMergeZone() now obsolete, does nothing\n", getpid());
101 warned = 1;
102 }
103}
104
105boolean_t NXProtectZone(malloc_zone_t *zone, int protection) {
106 fprintf(stderr, "*** malloc[%d]: NXProtectZone() is obsolete\n", getpid());
107 return 0;
108}
109
110malloc_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;
113 if (!warned) {
114 fprintf(stderr, "*** malloc[%d]: NXCreateChildZone() now obsolete, has been defined to create new zone\n", getpid());
115 warned = 1;
116 }
117 return NXCreateZone(startsize, granularity, canfree);
118}
119
120void _NXMallocDumpFrees(void) {
121 fprintf(stderr, "*** malloc[%d]: OBSOLETE: _NXMallocDumpFrees()\n", getpid());
122}
123