Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
SkAutoMalloc Class Reference

#include <SkAutoMalloc.h>

Inheritance diagram for SkAutoMalloc:
SkNoncopyable

Public Types

enum  OnShrink { kAlloc_OnShrink , kReuse_OnShrink }
 

Public Member Functions

 SkAutoMalloc (size_t size=0)
 
void * reset (size_t size=0, OnShrink shrink=kAlloc_OnShrink)
 
void * get ()
 
const void * get () const
 
void * release ()
 

Detailed Description

Manage an allocated block of heap memory. This object is the sole manager of the lifetime of the block, so the caller must not call sk_free() or delete on the block, unless release() was called.

Definition at line 25 of file SkAutoMalloc.h.

Member Enumeration Documentation

◆ OnShrink

Passed to reset to specify what happens if the requested size is smaller than the current size (and the current block was dynamically allocated).

Enumerator
kAlloc_OnShrink 

If the requested size is smaller than the current size, and the current block is dynamically allocated, free the old block and malloc a new block of the smaller size.

kReuse_OnShrink 

If the requested size is smaller than the current size, and the current block is dynamically allocated, just return the old block.

Definition at line 34 of file SkAutoMalloc.h.

34 {
35 /**
36 * If the requested size is smaller than the current size, and the
37 * current block is dynamically allocated, free the old block and
38 * malloc a new block of the smaller size.
39 */
41
42 /**
43 * If the requested size is smaller than the current size, and the
44 * current block is dynamically allocated, just return the old
45 * block.
46 */
48 };

Constructor & Destructor Documentation

◆ SkAutoMalloc()

SkAutoMalloc::SkAutoMalloc ( size_t  size = 0)
inlineexplicit

Definition at line 27 of file SkAutoMalloc.h.

28 : fPtr(size ? sk_malloc_throw(size) : nullptr), fSize(size) {}
static void * sk_malloc_throw(size_t size)
Definition SkMalloc.h:67
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

Member Function Documentation

◆ get() [1/2]

void * SkAutoMalloc::get ( )
inline

Return the allocated block.

Definition at line 64 of file SkAutoMalloc.h.

64{ return fPtr.get(); }

◆ get() [2/2]

const void * SkAutoMalloc::get ( ) const
inline

Definition at line 65 of file SkAutoMalloc.h.

65{ return fPtr.get(); }

◆ release()

void * SkAutoMalloc::release ( )
inline

Transfer ownership of the current ptr to the caller, setting the internal reference to null. Note the caller is reponsible for calling sk_free on the returned address.

Definition at line 71 of file SkAutoMalloc.h.

71 {
72 fSize = 0;
73 return fPtr.release();
74 }

◆ reset()

void * SkAutoMalloc::reset ( size_t  size = 0,
OnShrink  shrink = kAlloc_OnShrink 
)
inline

Reallocates the block to a new size. The ptr may or may not change.

Definition at line 53 of file SkAutoMalloc.h.

53 {
54 if (size != fSize && (size > fSize || kReuse_OnShrink != shrink)) {
55 fPtr.reset(size ? sk_malloc_throw(size) : nullptr);
56 fSize = size;
57 }
58 return fPtr.get();
59 }

The documentation for this class was generated from the following file: