17
17
#if _POSIX_THREADS
18
18
#include <pthread.h>
19
19
#endif
20
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
20
+ #if TARGET_OS_MAC
21
21
#include <malloc/malloc.h>
22
22
#include <mach/mach.h>
23
23
#include <dlfcn.h>
29
29
30
30
struct __CFAllocator {
31
31
CFRuntimeBase _base ;
32
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
32
+ #if TARGET_OS_MAC
33
33
// CFAllocator structure must match struct _malloc_zone_t!
34
34
// The first two reserved fields in struct _malloc_zone_t are for us with CFRuntimeBase
35
35
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 */
@@ -465,7 +465,7 @@ void CFAllocatorSetDefault(CFAllocatorRef allocator) {
465
465
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
466
466
}
467
467
#endif
468
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
468
+ #if TARGET_OS_MAC
469
469
if (allocator && allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
470
470
return ; // require allocator to this function to be an allocator
471
471
}
@@ -491,7 +491,7 @@ static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorC
491
491
CFAllocatorRetainCallBack retainFunc ;
492
492
CFAllocatorAllocateCallBack allocateFunc ;
493
493
void * retainedInfo ;
494
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
494
+ #if TARGET_OS_MAC
495
495
if (allocator && kCFAllocatorUseContext != allocator && allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
496
496
return NULL ; // require allocator to this function to be an allocator
497
497
}
@@ -525,7 +525,7 @@ static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorC
525
525
memset (memory , 0 , sizeof (CFRuntimeBase ));
526
526
__CFRuntimeSetRC (memory , 1 );
527
527
_CFAllocatorSetInstanceTypeIDAndIsa (memory );
528
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
528
+ #if TARGET_OS_MAC
529
529
memory -> size = __CFAllocatorCustomSize ;
530
530
memory -> malloc = __CFAllocatorCustomMalloc ;
531
531
memory -> calloc = __CFAllocatorCustomCalloc ;
@@ -574,7 +574,7 @@ void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags
574
574
allocator = __CFGetDefaultAllocator ();
575
575
}
576
576
577
- #if defined(DEBUG ) && ( TARGET_OS_OSX || TARGET_OS_IPHONE )
577
+ #if defined(DEBUG ) && TARGET_OS_MAC
578
578
if (allocator -> _base ._cfisa == __CFISAForCFAllocator ()) {
579
579
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
580
580
}
@@ -605,15 +605,15 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
605
605
allocator = __CFGetDefaultAllocator ();
606
606
}
607
607
608
- #if defined(DEBUG ) && ( TARGET_OS_OSX || TARGET_OS_IPHONE )
608
+ #if defined(DEBUG ) && TARGET_OS_MAC
609
609
if (allocator -> _base ._cfisa == __CFISAForCFAllocator ()) {
610
610
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
611
611
}
612
612
#else
613
613
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
614
614
#endif
615
615
if (NULL == ptr && 0 < newsize ) {
616
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
616
+ #if TARGET_OS_MAC
617
617
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
618
618
return malloc_zone_malloc ((malloc_zone_t * )allocator , newsize );
619
619
}
@@ -626,7 +626,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
626
626
return newptr ;
627
627
}
628
628
if (NULL != ptr && 0 == newsize ) {
629
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
629
+ #if TARGET_OS_MAC
630
630
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
631
631
#if defined(DEBUG )
632
632
size_t size = malloc_size (ptr );
@@ -643,7 +643,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
643
643
return NULL ;
644
644
}
645
645
if (NULL == ptr && 0 == newsize ) return NULL ;
646
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
646
+ #if TARGET_OS_MAC
647
647
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
648
648
return malloc_zone_realloc ((malloc_zone_t * )allocator , ptr , newsize );
649
649
}
@@ -661,14 +661,14 @@ void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr) {
661
661
allocator = __CFGetDefaultAllocator ();
662
662
}
663
663
664
- #if defined(DEBUG ) && ( TARGET_OS_OSX || TARGET_OS_IPHONE )
664
+ #if defined(DEBUG ) && TARGET_OS_MAC
665
665
if (allocator -> _base ._cfisa == __CFISAForCFAllocator ()) {
666
666
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
667
667
}
668
668
#else
669
669
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
670
670
#endif
671
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
671
+ #if TARGET_OS_MAC
672
672
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
673
673
#if defined(DEBUG )
674
674
size_t size = malloc_size (ptr );
@@ -691,14 +691,14 @@ CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex siz
691
691
allocator = __CFGetDefaultAllocator ();
692
692
}
693
693
694
- #if defined(DEBUG ) && ( TARGET_OS_OSX || TARGET_OS_IPHONE )
694
+ #if defined(DEBUG ) && TARGET_OS_MAC
695
695
if (allocator -> _base ._cfisa == __CFISAForCFAllocator ()) {
696
696
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
697
697
}
698
698
#else
699
699
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
700
700
#endif
701
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
701
+ #if TARGET_OS_MAC
702
702
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
703
703
return malloc_good_size (size );
704
704
}
@@ -716,15 +716,15 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
716
716
allocator = __CFGetDefaultAllocator ();
717
717
}
718
718
719
- #if defined(DEBUG ) && ( TARGET_OS_OSX || TARGET_OS_IPHONE )
719
+ #if defined(DEBUG ) && TARGET_OS_MAC
720
720
if (allocator -> _base ._cfisa == __CFISAForCFAllocator ()) {
721
721
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
722
722
}
723
723
#else
724
724
__CFGenericValidateType (allocator , _kCFRuntimeIDCFAllocator );
725
725
#endif
726
726
CFAssert1 (0 == context -> version , __kCFLogAssertion , "%s(): context version not initialized to 0" , __PRETTY_FUNCTION__ );
727
- #if TARGET_OS_OSX || TARGET_OS_IPHONE
727
+ #if TARGET_OS_MAC
728
728
if (allocator -> _base ._cfisa != __CFISAForCFAllocator ()) { // malloc_zone_t *
729
729
return ;
730
730
}
0 commit comments