Flutter Engine
The Flutter Engine
|
Go to the source code of this file.
Enumerations | |
enum | { SK_MALLOC_ZERO_INITIALIZE = 1 << 0 , SK_MALLOC_THROW = 1 << 1 } |
Functions | |
SK_API void | sk_free (void *) |
SK_API void | sk_out_of_memory (void) |
SK_API void * | sk_malloc_flags (size_t size, unsigned flags) |
SK_API void * | sk_realloc_throw (void *buffer, size_t size) |
SK_API size_t | sk_malloc_size (void *addr, size_t size) |
static void * | sk_malloc_throw (size_t size) |
static void * | sk_calloc_throw (size_t size) |
static void * | sk_calloc_canfail (size_t size) |
SK_API void * | sk_calloc_throw (size_t count, size_t elemSize) |
SK_API void * | sk_malloc_throw (size_t count, size_t elemSize) |
SK_API void * | sk_realloc_throw (void *buffer, size_t count, size_t elemSize) |
static void * | sk_malloc_canfail (size_t size) |
SK_API void * | sk_malloc_canfail (size_t count, size_t elemSize) |
static void | sk_bzero (void *buffer, size_t size) |
static void * | sk_careful_memcpy (void *dst, const void *src, size_t len) |
static void * | sk_careful_memmove (void *dst, const void *src, size_t len) |
static int | sk_careful_memcmp (const void *a, const void *b, size_t len) |
anonymous enum |
Definition at line 29 of file SkMalloc.h.
|
inlinestatic |
Definition at line 105 of file SkMalloc.h.
|
inlinestatic |
Definition at line 75 of file SkMalloc.h.
|
extern |
Definition at line 8 of file SkMalloc.cpp.
|
inlinestatic |
Definition at line 71 of file SkMalloc.h.
|
inlinestatic |
Definition at line 143 of file SkMalloc.h.
|
inlinestatic |
sk_careful_memcpy() is just like memcpy(), but guards against undefined behavior.
It is undefined behavior to call memcpy() with null dst or src, even if len is 0. If an optimizer is "smart" enough, it can exploit this to do unexpected things. memcpy(dst, src, 0); if (src) { printf("%x\n", *src); } In this code the compiler can assume src is not null and omit the if (src) {...} check, unconditionally running the printf, crashing the program if src really is null. Of the compilers we pay attention to only GCC performs this optimization in practice.
Definition at line 125 of file SkMalloc.h.
|
inlinestatic |
Definition at line 134 of file SkMalloc.h.
|
extern |
Free memory returned by sk_malloc(). It is safe to pass null.
Definition at line 83 of file SkMemory_malloc.cpp.
|
extern |
Definition at line 20 of file SkMalloc.cpp.
|
inlinestatic |
These variants return nullptr on failure
Definition at line 93 of file SkMalloc.h.
|
extern |
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 91 of file SkMemory_malloc.cpp.
|
extern |
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 119 of file SkMemory_malloc.cpp.
|
extern |
Definition at line 12 of file SkMalloc.cpp.
|
inlinestatic |
Definition at line 67 of file SkMalloc.h.
|
extern |
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 66 of file SkMemory_malloc.cpp.
|
extern |
Definition at line 16 of file SkMalloc.cpp.
|
extern |
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 75 of file SkMemory_malloc.cpp.