diff options
author | george@mozilla.com <george@mozilla.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-27 19:56:43 +0000 |
---|---|---|
committer | george@mozilla.com <george@mozilla.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-27 19:56:43 +0000 |
commit | cb39ee645a32b7e15a813672ac0acfd7e8dc114b (patch) | |
tree | 8163c02af8db53a566c05b6b9f76944efa5a8808 | |
parent | 405ebbcade9c30406911ed001126179084ee0e1a (diff) |
Add a new SkMemory implementation that uses mozalloc instead of malloc
git-svn-id: http://skia.googlecode.com/svn/trunk@5292 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/ports/SkMemory_mozalloc.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/ports/SkMemory_mozalloc.cpp b/src/ports/SkMemory_mozalloc.cpp new file mode 100644 index 0000000000..1f16ee5808 --- /dev/null +++ b/src/ports/SkMemory_mozalloc.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2011 Google Inc. + * Copyright 2012 Mozilla Foundation + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkTypes.h" + +#include "mozilla/mozalloc.h" +#include "mozilla/mozalloc_abort.h" +#include "mozilla/mozalloc_oom.h" + +void sk_throw() { + SkDEBUGFAIL("sk_throw"); + mozalloc_abort("Abort from sk_throw"); +} + +void sk_out_of_memory(void) { + SkDEBUGFAIL("sk_out_of_memory"); + mozalloc_handle_oom(0); +} + +void* sk_malloc_throw(size_t size) { + return sk_malloc_flags(size, SK_MALLOC_THROW); +} + +void* sk_realloc_throw(void* addr, size_t size) { + return moz_xrealloc(addr, size); +} + +void sk_free(void* p) { + moz_free(p); +} + +void* sk_malloc_flags(size_t size, unsigned flags) { + return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : moz_malloc(size); +} + |