android fixes

This commit is contained in:
mannewalis 2014-12-15 16:21:12 -08:00
parent b532ce74d8
commit a095635459
6 changed files with 32 additions and 19 deletions

View File

@ -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 \

View File

@ -29,6 +29,7 @@
#include "platform/CCPlatformMacros.h"
#include "base/allocator/CCAllocatorMacros.h"
#include <string>
NS_CC_BEGIN
NS_CC_ALLOCATOR_BEGIN

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -12,4 +12,4 @@
android.library=true
# Project target.
target=android-10
target=android-19