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