Tizen 2.1 base
[platform/upstream/gcd.git] / dispatch-1.0 / 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         return ((malloc_zone_t *)(-1));
39 }
40
41 static inline void
42 malloc_destroy_zone(malloc_zone_t *zone)
43 {
44         /* No-op. */
45 }
46
47 static inline malloc_zone_t *
48 malloc_default_zone(void)
49 {
50         return ((malloc_zone_t *)(-1));
51 }
52
53 static inline malloc_zone_t *
54 malloc_zone_from_ptr(const void *ptr)
55 {
56         return ((malloc_zone_t *)(-1));
57 }
58
59 static inline void *
60 malloc_zone_malloc(malloc_zone_t *zone, size_t size)
61 {
62         return (malloc(size));
63 }
64
65 static inline void *
66 malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size)
67 {
68         return (calloc(num_items, size));
69 }
70
71 static inline void *
72 malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
73 {
74         return (realloc(ptr, size));
75 }
76
77 static inline void
78 malloc_zone_free(malloc_zone_t *zone, void *ptr)
79 {
80         free(ptr);
81 }
82
83 static inline void
84 malloc_set_zone_name(malloc_zone_t *zone, const char *name)
85 {
86         /* No-op. */
87 }
88 #endif /* !HAVE_MALLOC_CREATE_ZONE */
89
90 #endif /* __DISPATCH_SHIMS_MALLOC_ZONE__ */