1/* libs/graphics/ports/SkMemory_brew.cpp 2** 3** Copyright 2009, The Android Open Source Project 4** Copyright 2009, Company 100, Inc. 5** 6** Licensed under the Apache License, Version 2.0 (the "License"); 7** you may not use this file except in compliance with the License. 8** You may obtain a copy of the License at 9** 10** http://www.apache.org/licenses/LICENSE-2.0 11** 12** Unless required by applicable law or agreed to in writing, software 13** distributed under the License is distributed on an "AS IS" BASIS, 14** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15** See the License for the specific language governing permissions and 16** limitations under the License. 17*/ 18 19#include "SkTypes.h" 20 21#ifdef SK_BUILD_FOR_BREW 22 23#include <AEEStdLib.h> 24 25void sk_throw() { 26 SkASSERT(!"sk_throw"); 27 abort(); 28} 29 30void sk_out_of_memory(void) { 31 SkASSERT(!"sk_out_of_memory"); 32 abort(); 33} 34 35void* sk_malloc_throw(size_t size) { 36 return sk_malloc_flags(size, SK_MALLOC_THROW); 37} 38 39void* sk_realloc_throw(void* addr, size_t size) { 40 void* p = REALLOC(addr, size | ALLOC_NO_ZMEM); 41 if (size == 0) { 42 return p; 43 } 44 if (p == NULL) { 45 sk_throw(); 46 } 47 return p; 48} 49 50void sk_free(void* p) { 51 FREEIF(p); 52} 53 54void* sk_malloc_flags(size_t size, unsigned flags) { 55 void* p = MALLOC(size | ALLOC_NO_ZMEM); 56 if (p == NULL) { 57 if (flags & SK_MALLOC_THROW) { 58 sk_throw(); 59 } 60 } 61 return p; 62} 63 64#endif 65 66