OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2009 Apple Inc. All rights reserved. | 2 * Copyright (c) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * @APPLE_LICENSE_HEADER_START@ | 4 * @APPLE_LICENSE_HEADER_START@ |
5 * | 5 * |
6 * This file contains Original Code and/or Modifications of Original Code | 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 | 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 | 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 | 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 | 10 * http://www.opensource.apple.com/apsl/ and read it before using this |
11 * file. | 11 * file. |
12 * | 12 * |
13 * The Original Code and all software distributed under the License are | 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 | 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 * Please see the License for the specific language governing rights and | 18 * Please see the License for the specific language governing rights and |
19 * limitations under the License. | 19 * limitations under the License. |
20 * | 20 * |
21 * @APPLE_LICENSE_HEADER_END@ | 21 * @APPLE_LICENSE_HEADER_END@ |
22 */ | 22 */ |
23 /* CFBase.c | 23 /* CFBase.c |
24 » Copyright (c) 1998-2009, Apple Inc. All rights reserved. | 24 » Copyright (c) 1998-2011, Apple Inc. All rights reserved. |
25 Responsibility: Christopher Kane | 25 Responsibility: Christopher Kane |
26 */ | 26 */ |
27 | 27 |
28 #ifndef THIRD_PARTY_APPLE_APSL_CFBASE_H_ | 28 #ifndef THIRD_PARTY_APPLE_APSL_CFBASE_H_ |
29 #define THIRD_PARTY_APPLE_APSL_CFBASE_H_ | 29 #define THIRD_PARTY_APPLE_APSL_CFBASE_H_ |
30 | 30 |
31 #include "CFRuntime.h" | 31 #include "CFRuntime.h" |
32 | 32 |
33 struct ChromeCFAllocatorLeopards { | 33 struct ChromeCFAllocatorLeopards { |
34 ChromeCFRuntimeBase _base; | 34 ChromeCFRuntimeBase _base; |
35 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED | 35 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED |
36 size_t (*size)(struct _malloc_zone_t *zone, const void *ptr); /* returns the
size of a block or 0 if not in this zone; must be fast, especially for negative
answers */ | 36 size_t (*size)(struct _malloc_zone_t *zone, const void *ptr); /* returns the
size of a block or 0 if not in this zone; must be fast, especially for negative
answers */ |
37 void *(*malloc)(struct _malloc_zone_t *zone, size_t size); | 37 void *(*malloc)(struct _malloc_zone_t *zone, size_t size); |
38 void *(*calloc)(struct _malloc_zone_t *zone, size_t num_items, size_t size);
/* same as malloc, but block returned is set to zero */ | 38 void *(*calloc)(struct _malloc_zone_t *zone, size_t num_items, size_t size);
/* same as malloc, but block returned is set to zero */ |
39 void *(*valloc)(struct _malloc_zone_t *zone, size_t size); /* same as malloc
, but block returned is set to zero and is guaranteed to be page aligned */ | 39 void *(*valloc)(struct _malloc_zone_t *zone, size_t size); /* same as malloc
, but block returned is set to zero and is guaranteed to be page aligned */ |
40 void (*free)(struct _malloc_zone_t *zone, void *ptr); | 40 void (*free)(struct _malloc_zone_t *zone, void *ptr); |
41 void *(*realloc)(struct _malloc_zone_t *zone, void *ptr, size_t size); | 41 void *(*realloc)(struct _malloc_zone_t *zone, void *ptr, size_t size); |
42 void (*destroy)(struct _malloc_zone_t *zone); /* zone is destroyed and all m
emory reclaimed */ | 42 void (*destroy)(struct _malloc_zone_t *zone); /* zone is destroyed and all m
emory reclaimed */ |
43 const char *zone_name; | 43 const char *zone_name; |
44 unsigned (*batch_malloc)(struct _malloc_zone_t *zone, size_t size, void **re
sults, unsigned num_requested); /* given a size, returns pointers capable of hol
ding that size; returns the number of pointers allocated (maybe 0 or less than n
um_requested) */ | 44 unsigned (*batch_malloc)(struct _malloc_zone_t *zone, size_t size, void **re
sults, unsigned num_requested); /* given a size, returns pointers capable of hol
ding that size; returns the number of pointers allocated (maybe 0 or less than n
um_requested) */ |
45 void (*batch_free)(struct _malloc_zone_t *zone, void **to_be_freed, unsigned
num_to_be_freed); /* frees all the pointers in to_be_freed; note that to_be_fre
ed may be overwritten during the process */ | 45 void (*batch_free)(struct _malloc_zone_t *zone, void **to_be_freed, unsigned
num_to_be_freed); /* frees all the pointers in to_be_freed; note that to_be_fre
ed may be overwritten during the process */ |
46 struct malloc_introspection_t *introspect; | 46 struct malloc_introspection_t *introspect; |
47 void *reserved5; | 47 void *reserved5; |
48 #endif | 48 #endif |
49 CFAllocatorRef _allocator; | 49 CFAllocatorRef _allocator; |
50 CFAllocatorContext _context; | 50 CFAllocatorContext _context; |
51 }; | 51 }; |
52 | 52 |
53 // TODO(avi): update upon source release; http://crbug.com/74589 | |
54 struct ChromeCFAllocatorLion { | 53 struct ChromeCFAllocatorLion { |
55 ChromeCFRuntimeBase _base; | 54 ChromeCFRuntimeBase _base; |
56 // CFAllocator in Darwin 9 included a complete copy of _malloc_zone_t. The | 55 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED |
57 // version in Darwin 10 had an abbreviated _malloc_zone_t that ended after the | 56 size_t » (*size)(struct _malloc_zone_t *zone, const void *ptr); /* return
s the size of a block or 0 if not in this zone; must be fast, especially for neg
ative answers */ |
58 // version/"reserved" field (see above). Darwin 11 appears to have a truncated | 57 void » *(*malloc)(struct _malloc_zone_t *zone, size_t size); |
59 // _malloc_zone_t as well, but two fields larger than 9/10. | 58 void » *(*calloc)(struct _malloc_zone_t *zone, size_t num_items, size_t
size); /* same as malloc, but block returned is set to zero */ |
60 void* presumedSizeFunctionPtr; | 59 void » *(*valloc)(struct _malloc_zone_t *zone, size_t size); /* same as
malloc, but block returned is set to zero and is guaranteed to be page aligned
*/ |
61 void* presumedMallocFunctionPtr; | 60 void » (*free)(struct _malloc_zone_t *zone, void *ptr); |
62 void* presumedCallocFunctionPtr; | 61 void » *(*realloc)(struct _malloc_zone_t *zone, void *ptr, size_t size)
; |
63 void* presumedVallocFunctionPtr; | 62 void » (*destroy)(struct _malloc_zone_t *zone); /* zone is destroyed an
d all memory reclaimed */ |
64 void* presumedFreeFunctionPtr; | 63 const char» *zone_name; |
65 void* presumedReallocFunctionPtr; | 64 |
66 void* presumedDestroyFunctionPtr; | 65 /* Optional batch callbacks; these may be NULL */ |
67 const char *zone_name; | 66 unsigned» (*batch_malloc)(struct _malloc_zone_t *zone, size_t size, void *
*results, unsigned num_requested); /* given a size, returns pointers capable of
holding that size; returns the number of pointers allocated (maybe 0 or less tha
n num_requested) */ |
68 void* presumedBatchMallocFunctionPtr; | 67 void» (*batch_free)(struct _malloc_zone_t *zone, void **to_be_freed, u
nsigned num_to_be_freed); /* frees all the pointers in to_be_freed; note that to
_be_freed may be overwritten during the process */ |
69 void* presumedBatchFreeFunctionPtr; | 68 |
70 void* presumedIntrospectStructPtr; | 69 struct malloc_introspection_t» *introspect; |
71 void* presumedReservedSlashVersion; // always 6 in CFAllocators | 70 unsigned» version; |
72 void* presumedMemalignFunctionPtr; | 71 |
73 void* presumedFreeDefiniteSizeFunctionPtr; | 72 /* aligned memory allocation. The callback may be NULL. */ |
74 CFAllocatorRef _allocator; | 73 » void *(*memalign)(struct _malloc_zone_t *zone, size_t alignment, size_t
size); |
75 CFAllocatorContext _context; | 74 |
| 75 /* free a pointer known to be in zone and known to have the given size. The
callback may be NULL. */ |
| 76 void (*free_definite_size)(struct _malloc_zone_t *zone, void *ptr, size_t si
ze); |
| 77 #endif |
| 78 CFAllocatorRef _allocator; |
| 79 CFAllocatorContext _context; |
76 }; | 80 }; |
77 | 81 |
78 #endif // THIRD_PARTY_APPLE_APSL_CFBASE_H_ | 82 #endif // THIRD_PARTY_APPLE_APSL_CFBASE_H_ |
OLD | NEW |