2 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __DISPATCH_SHIMS_MALLOC_ZONE__
22 #define __DISPATCH_SHIMS_MALLOC_ZONE__
24 #include <sys/types.h>
29 * Implement malloc zones as a simple wrapper around malloc(3) on systems
30 * that don't support them.
32 #if !HAVE_MALLOC_CREATE_ZONE
33 typedef void * malloc_zone_t;
35 static inline malloc_zone_t *
36 malloc_create_zone(size_t start_size, unsigned flags)
38 return ((malloc_zone_t *)(-1));
42 malloc_destroy_zone(malloc_zone_t *zone)
47 static inline malloc_zone_t *
48 malloc_default_zone(void)
50 return ((malloc_zone_t *)(-1));
53 static inline malloc_zone_t *
54 malloc_zone_from_ptr(const void *ptr)
56 return ((malloc_zone_t *)(-1));
60 malloc_zone_malloc(malloc_zone_t *zone, size_t size)
62 return (malloc(size));
66 malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size)
68 return (calloc(num_items, size));
72 malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
74 return (realloc(ptr, size));
78 malloc_zone_free(malloc_zone_t *zone, void *ptr)
84 malloc_set_zone_name(malloc_zone_t *zone, const char *name)
88 #endif /* !HAVE_MALLOC_CREATE_ZONE */
90 #endif /* __DISPATCH_SHIMS_MALLOC_ZONE__ */