1 /* libs/graphics/ports/SkMemory_brew.cpp 2 * 3 * Copyright 2009, The Android Open Source Project 4 * Copyright 2009, Company 100, Inc. 5 * 6 * Use of this source code is governed by a BSD-style license that can be 7 * found in the LICENSE file. 8 */ 9 10 #include "SkTypes.h" 11 12 #ifdef SK_BUILD_FOR_BREW 13 14 #include <AEEStdLib.h> 15 16 void sk_throw() { 17 SkDEBUGFAIL("sk_throw"); 18 abort(); 19 } 20 21 void sk_out_of_memory(void) { 22 SkDEBUGFAIL("sk_out_of_memory"); 23 abort(); 24 } 25 26 void* sk_malloc_throw(size_t size) { 27 return sk_malloc_flags(size, SK_MALLOC_THROW); 28 } 29 30 void* sk_realloc_throw(void* addr, size_t size) { 31 void* p = REALLOC(addr, size | ALLOC_NO_ZMEM); 32 if (size == 0) { 33 return p; 34 } 35 if (p == NULL) { 36 sk_throw(); 37 } 38 return p; 39 } 40 41 void sk_free(void* p) { 42 FREEIF(p); 43 } 44 45 void* sk_malloc_flags(size_t size, unsigned flags) { 46 void* p = MALLOC(size | ALLOC_NO_ZMEM); 47 if (p == NULL) { 48 if (flags & SK_MALLOC_THROW) { 49 sk_throw(); 50 } 51 } 52 return p; 53 } 54 55 #endif 56