reed@google.com | c332b3f | 2011-02-07 20:01:58 +0000 | [diff] [blame] | 1 | /* libs/graphics/ports/SkMemory_brew.cpp |
epoger@google.com | fd03db0 | 2011-07-28 14:24:55 +0000 | [diff] [blame] | 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 | */ |
reed@google.com | c332b3f | 2011-02-07 20:01:58 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkTypes.h" |
| 11 | |
| 12 | #ifdef SK_BUILD_FOR_BREW |
| 13 | |
| 14 | #include <AEEStdLib.h> |
| 15 | |
| 16 | void sk_throw() { |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 17 | SkDEBUGFAIL("sk_throw"); |
reed@google.com | c332b3f | 2011-02-07 20:01:58 +0000 | [diff] [blame] | 18 | abort(); |
| 19 | } |
| 20 | |
| 21 | void sk_out_of_memory(void) { |
tomhudson@google.com | 0c00f21 | 2011-12-28 14:59:50 +0000 | [diff] [blame] | 22 | SkDEBUGFAIL("sk_out_of_memory"); |
reed@google.com | c332b3f | 2011-02-07 20:01:58 +0000 | [diff] [blame] | 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 |