Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkMemory_mozalloc.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 * Copyright 2012 Mozilla Foundation
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
10
12#include "mozilla/mozalloc.h"
13#include "mozilla/mozalloc_abort.h"
14#include "mozilla/mozalloc_oom.h"
15
16// needed for std::max
17#include <algorithm>
18
20 mozalloc_abort("Abort from sk_abort");
21}
22
23void sk_out_of_memory(void) {
24 SkDEBUGFAIL("sk_out_of_memory");
25 mozalloc_handle_oom(0);
26}
27
28void sk_free(void* p) {
29 free(p);
30}
31
32void* sk_realloc_throw(void* addr, size_t size) {
33 return moz_xrealloc(addr, size);
34}
35
36void* sk_malloc_flags(size_t size, unsigned flags) {
38 return (flags & SK_MALLOC_THROW) ? moz_xcalloc(size, 1) : calloc(size, 1);
39 }
40 return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : malloc(size);
41}
42
43size_t sk_malloc_size(void* addr, size_t size) {
44 return std::max(moz_malloc_usable_size(addr), size);
45}
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
@ SK_MALLOC_ZERO_INITIALIZE
Definition SkMalloc.h:34
@ SK_MALLOC_THROW
Definition SkMalloc.h:40
void * sk_malloc_flags(size_t size, unsigned flags)
void sk_free(void *p)
size_t sk_malloc_size(void *addr, size_t size)
void * sk_realloc_throw(void *addr, size_t size)
void sk_abort_no_print()
void sk_out_of_memory(void)
FlutterSemanticsFlag flags