blob: 96af7021e61aeb04a9d0bf8fc3c5f5f7ed0cf8a0 [file] [log] [blame]
reed@google.comc332b3f2011-02-07 20:01:58 +00001/* libs/graphics/ports/SkMemory_brew.cpp
epoger@google.comfd03db02011-07-28 14:24:55 +00002 *
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.comc332b3f2011-02-07 20:01:58 +00009
10#include "SkTypes.h"
11
12#ifdef SK_BUILD_FOR_BREW
13
14#include <AEEStdLib.h>
15
16void sk_throw() {
tomhudson@google.com0c00f212011-12-28 14:59:50 +000017 SkDEBUGFAIL("sk_throw");
reed@google.comc332b3f2011-02-07 20:01:58 +000018 abort();
19}
20
21void sk_out_of_memory(void) {
tomhudson@google.com0c00f212011-12-28 14:59:50 +000022 SkDEBUGFAIL("sk_out_of_memory");
reed@google.comc332b3f2011-02-07 20:01:58 +000023 abort();
24}
25
26void* sk_malloc_throw(size_t size) {
27 return sk_malloc_flags(size, SK_MALLOC_THROW);
28}
29
30void* 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
41void sk_free(void* p) {
42 FREEIF(p);
43}
44
45void* 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