]> git.saurik.com Git - apple/libdispatch.git/blob - src/shims/malloc_zone.h
libdispatch-187.5.tar.gz
[apple/libdispatch.git] / src / shims / malloc_zone.h
1 /*
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 #ifndef __DISPATCH_SHIMS_MALLOC_ZONE__
22 #define __DISPATCH_SHIMS_MALLOC_ZONE__
23
24 #include <sys/types.h>
25
26 #include <stdlib.h>
27
28 /*
29 * Implement malloc zones as a simple wrapper around malloc(3) on systems
30 * that don't support them.
31 */
32 #if !HAVE_MALLOC_CREATE_ZONE
33 typedef void * malloc_zone_t;
34
35 static inline malloc_zone_t *
36 malloc_create_zone(size_t start_size, unsigned flags)
37 {
38
39 return ((void *)(-1));
40 }
41
42 static inline void
43 malloc_destroy_zone(malloc_zone_t *zone)
44 {
45
46 }
47
48 static inline malloc_zone_t *
49 malloc_default_zone(void)
50 {
51
52 return ((void *)(-1));
53 }
54
55 static inline malloc_zone_t *
56 malloc_zone_from_ptr(const void *ptr)
57 {
58
59 return ((void *)(-1));
60 }
61
62 static inline void *
63 malloc_zone_malloc(malloc_zone_t *zone, size_t size)
64 {
65
66 return (malloc(size));
67 }
68
69 static inline void *
70 malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size)
71 {
72
73 return (calloc(num_items, size));
74 }
75
76 static inline void *
77 malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
78 {
79
80 return (realloc(ptr, size));
81 }
82
83 static inline void
84 malloc_zone_free(malloc_zone_t *zone, void *ptr)
85 {
86
87 free(ptr);
88 }
89
90 static inline void
91 malloc_set_zone_name(malloc_zone_t *zone, const char *name)
92 {
93
94 /* No-op. */
95 }
96 #endif
97
98 #endif /* __DISPATCH_SHIMS_MALLOC_ZONE__ */