Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkMemory_mozalloc.cpp File Reference
#include "include/private/base/SkMalloc.h"
#include "include/core/SkTypes.h"
#include "mozilla/mozalloc.h"
#include "mozilla/mozalloc_abort.h"
#include "mozilla/mozalloc_oom.h"
#include <algorithm>

Go to the source code of this file.

Functions

void sk_abort_no_print ()
 
void sk_out_of_memory (void)
 
void sk_free (void *p)
 
void * sk_realloc_throw (void *addr, size_t size)
 
void * sk_malloc_flags (size_t size, unsigned flags)
 
size_t sk_malloc_size (void *addr, size_t size)
 

Function Documentation

◆ sk_abort_no_print()

void sk_abort_no_print ( void  )

Called internally if we hit an unrecoverable error. The platform implementation must not return, but should either throw an exception or otherwise exit.

Definition at line 19 of file SkMemory_mozalloc.cpp.

19 {
20 mozalloc_abort("Abort from sk_abort");
21}

◆ sk_free()

void sk_free ( void *  p)

Free memory returned by sk_malloc(). It is safe to pass null.

Definition at line 28 of file SkMemory_mozalloc.cpp.

28 {
29 free(p);
30}

◆ sk_malloc_flags()

void * sk_malloc_flags ( size_t  size,
unsigned  flags 
)

Return a block of memory (at least 4-byte aligned) of at least the specified size. If the requested memory cannot be returned, either return nullptr or throw/exit, depending on the SK_MALLOC_THROW bit. If the allocation succeeds, the memory will be zero-initialized if the SK_MALLOC_ZERO_INITIALIZE bit was set.

To free the memory, call sk_free()

Definition at line 36 of file SkMemory_mozalloc.cpp.

36 {
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}
@ SK_MALLOC_ZERO_INITIALIZE
Definition SkMalloc.h:34
@ SK_MALLOC_THROW
Definition SkMalloc.h:40
FlutterSemanticsFlag flags
void * malloc(size_t size)
Definition allocation.cc:19
void * calloc(size_t n, size_t size)
Definition allocation.cc:11
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ sk_malloc_size()

size_t sk_malloc_size ( void *  addr,
size_t  size 
)

Return the size of the block of memory allocated in reality for a given pointer. The pointer passed must have been allocated using the sk_malloc_* or sk_realloc_* functions. The "size" parameter indicates the size originally requested when the memory block was allocated, and the value returned by this function must be bigger or equal to it.

Definition at line 43 of file SkMemory_mozalloc.cpp.

43 {
44 return std::max(moz_malloc_usable_size(addr), size);
45}

◆ sk_out_of_memory()

void sk_out_of_memory ( void  )

Called internally if we run out of memory. The platform implementation must not return, but should either throw an exception or otherwise exit.

Definition at line 23 of file SkMemory_mozalloc.cpp.

23 {
24 SkDEBUGFAIL("sk_out_of_memory");
25 mozalloc_handle_oom(0);
26}
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118

◆ sk_realloc_throw()

void * sk_realloc_throw ( void *  buffer,
size_t  size 
)

Same as standard realloc(), but this one never returns null on failure. It will throw if it fails. If size is 0, it will call sk_free on buffer and return null. (This behavior is implementation- defined for normal realloc. We follow what glibc does.)

Definition at line 32 of file SkMemory_mozalloc.cpp.

32 {
33 return moz_xrealloc(addr, size);
34}