From a095635459cf31c197ae74dac3d997c96b162213 Mon Sep 17 00:00:00 2001 From: mannewalis Date: Mon, 15 Dec 2014 16:21:12 -0800 Subject: [PATCH] android fixes --- cocos/Android.mk | 3 ++ cocos/base/allocator/CCAllocatorBase.h | 1 + cocos/base/allocator/CCAllocatorDiagnostics.h | 5 ++- .../allocator/CCAllocatorGlobalNewDelete.cpp | 6 ++++ .../CCAllocatorStrategyGlobalSmallBlock.h | 34 +++++++++++-------- .../platform/android/java/project.properties | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/cocos/Android.mk b/cocos/Android.mk index 518c888e31..662e3a9687 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -140,6 +140,9 @@ base/pvr.cpp \ base/s3tc.cpp \ base/CCController.cpp \ base/CCController-android.cpp \ +base/allocator/CCAllocatorDiagnostics.cpp \ +base/allocator/CCAllocatorGlobal.cpp \ +base/allocator/CCAllocatorGlobalNewDelete.cpp \ base/ObjectFactory.cpp \ renderer/CCBatchCommand.cpp \ renderer/CCCustomCommand.cpp \ diff --git a/cocos/base/allocator/CCAllocatorBase.h b/cocos/base/allocator/CCAllocatorBase.h index bc83bd65d0..d100b33345 100644 --- a/cocos/base/allocator/CCAllocatorBase.h +++ b/cocos/base/allocator/CCAllocatorBase.h @@ -29,6 +29,7 @@ #include "platform/CCPlatformMacros.h" #include "base/allocator/CCAllocatorMacros.h" +#include NS_CC_BEGIN NS_CC_ALLOCATOR_BEGIN diff --git a/cocos/base/allocator/CCAllocatorDiagnostics.h b/cocos/base/allocator/CCAllocatorDiagnostics.h index b23c00a429..5172855b41 100644 --- a/cocos/base/allocator/CCAllocatorDiagnostics.h +++ b/cocos/base/allocator/CCAllocatorDiagnostics.h @@ -52,10 +52,9 @@ protected: AllocatorMutex _mutex; AllocatorBase* _allocators; }; - -#endif +#endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS NS_CC_ALLOCATOR_END NS_CC_END -#endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS +#endif//CC_ALLOCATOR_DIAGNOSTICS_H diff --git a/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp b/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp index 1b2348df59..72098a1375 100644 --- a/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp +++ b/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp @@ -30,6 +30,7 @@ USING_NS_CC_ALLOCATOR; +#if CC_ENABLE_ALLOCATOR #if CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE namespace @@ -42,8 +43,10 @@ namespace void* operator new[] (std::size_t size) { void* ptr = global.allocate(size); +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID if (nullptr == ptr) throw std::bad_alloc(); +#endif return ptr; } @@ -51,8 +54,10 @@ void* operator new[] (std::size_t size) void* operator new(std::size_t size) { void* ptr = global.allocate(size); +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID if (nullptr == ptr) throw std::bad_alloc(); +#endif return ptr; } @@ -64,3 +69,4 @@ void operator delete(void* p) throw() } #endif // CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE +#endif // CC_ENABLE_ALLOCATOR diff --git a/cocos/base/allocator/CCAllocatorStrategyGlobalSmallBlock.h b/cocos/base/allocator/CCAllocatorStrategyGlobalSmallBlock.h index 1f508d57a4..279b9c9d84 100644 --- a/cocos/base/allocator/CCAllocatorStrategyGlobalSmallBlock.h +++ b/cocos/base/allocator/CCAllocatorStrategyGlobalSmallBlock.h @@ -182,7 +182,9 @@ public: ALLOCATE(13, 8192); default: CC_ASSERT(false); +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID throw std::bad_alloc(); +#endif break; } @@ -261,21 +263,23 @@ public: switch (adjusted_size) { - DEALLOCATE(2, 4, address); - DEALLOCATE(3, 8, address); - DEALLOCATE(4, 16, address); - DEALLOCATE(5, 32, address); - DEALLOCATE(6, 64, address); - DEALLOCATE(7, 128, address); - DEALLOCATE(8, 256, address); - DEALLOCATE(9, 512, address); - DEALLOCATE(10, 1024, address); - DEALLOCATE(11, 2048, address); - DEALLOCATE(12, 4096, address); - DEALLOCATE(13, 8192, address); - default: - CC_ASSERT(false); - throw std::bad_alloc(); + DEALLOCATE(2, 4, address); + DEALLOCATE(3, 8, address); + DEALLOCATE(4, 16, address); + DEALLOCATE(5, 32, address); + DEALLOCATE(6, 64, address); + DEALLOCATE(7, 128, address); + DEALLOCATE(8, 256, address); + DEALLOCATE(9, 512, address); + DEALLOCATE(10, 1024, address); + DEALLOCATE(11, 2048, address); + DEALLOCATE(12, 4096, address); + DEALLOCATE(13, 8192, address); + default: + CC_ASSERT(false); +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID + throw std::bad_alloc(); +#endif } #undef DEALLOCATE diff --git a/cocos/platform/android/java/project.properties b/cocos/platform/android/java/project.properties index 88ca83f9d0..61afc8fe54 100644 --- a/cocos/platform/android/java/project.properties +++ b/cocos/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-10 +target=android-19