Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::ClassTableAllocator Class Reference

#include <class_table.h>

Inheritance diagram for dart::ClassTableAllocator:
dart::ValueObject

Public Member Functions

 ClassTableAllocator ()
 
 ~ClassTableAllocator ()
 
template<class T >
TAlloc (intptr_t len)
 
template<class T >
TAllocZeroInitialized (intptr_t len)
 
template<class T >
TClone (T *array, intptr_t size)
 
template<class T >
TRealloc (T *array, intptr_t size, intptr_t new_size)
 
void Free (ClassTable *table)
 
void Free (void *ptr)
 
void FreePending ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 84 of file class_table.h.

Constructor & Destructor Documentation

◆ ClassTableAllocator()

dart::ClassTableAllocator::ClassTableAllocator ( )

Definition at line 381 of file class_table.cc.

382 : pending_freed_(new MallocGrowableArray<std::pair<void*, Deleter>>()) {}

◆ ~ClassTableAllocator()

dart::ClassTableAllocator::~ClassTableAllocator ( )

Definition at line 384 of file class_table.cc.

384 {
385 FreePending();
386 delete pending_freed_;
387}

Member Function Documentation

◆ Alloc()

template<class T >
T * dart::ClassTableAllocator::Alloc ( intptr_t  len)
inline

Definition at line 93 of file class_table.h.

93 {
94 return reinterpret_cast<T*>(dart::malloc(len * sizeof(T)));
95 }
void * malloc(size_t size)
Definition allocation.cc:19
#define T

◆ AllocZeroInitialized()

template<class T >
T * dart::ClassTableAllocator::AllocZeroInitialized ( intptr_t  len)
inline

Definition at line 99 of file class_table.h.

99 {
100 return reinterpret_cast<T*>(dart::calloc(len, sizeof(T)));
101 }
void * calloc(size_t n, size_t size)
Definition allocation.cc:11

◆ Clone()

template<class T >
T * dart::ClassTableAllocator::Clone ( T array,
intptr_t  size 
)
inline

Definition at line 105 of file class_table.h.

105 {
106 if (array == nullptr) {
107 ASSERT(size == 0);
108 return nullptr;
109 }
110 auto result = Alloc<T>(size);
111 memmove(result, array, size * sizeof(T));
112 return result;
113 }
#define ASSERT(E)
GAsyncResult * result

◆ Free() [1/2]

void dart::ClassTableAllocator::Free ( ClassTable table)

Definition at line 389 of file class_table.cc.

389 {
390 if (ptr != nullptr) {
391 pending_freed_->Add(std::make_pair(
392 ptr, [](void* ptr) { delete static_cast<ClassTable*>(ptr); }));
393 }
394}
void Add(const T &value)

◆ Free() [2/2]

void dart::ClassTableAllocator::Free ( void *  ptr)

Definition at line 396 of file class_table.cc.

396 {
397 if (ptr != nullptr) {
398 pending_freed_->Add(std::make_pair(ptr, nullptr));
399 }
400}

◆ FreePending()

void dart::ClassTableAllocator::FreePending ( )

Definition at line 402 of file class_table.cc.

402 {
403 while (!pending_freed_->is_empty()) {
404 auto [ptr, deleter] = pending_freed_->RemoveLast();
405 if (deleter == nullptr) {
406 free(ptr);
407 } else {
408 deleter(ptr);
409 }
410 }
411}

◆ Realloc()

template<class T >
T * dart::ClassTableAllocator::Realloc ( T array,
intptr_t  size,
intptr_t  new_size 
)
inline

Definition at line 121 of file class_table.h.

121 {
122 ASSERT(size < new_size);
123 auto result = AllocZeroInitialized<T>(new_size);
124 if (size != 0) {
125 ASSERT(result != nullptr);
126 memmove(result, array, size * sizeof(T));
127 }
128 Free(array);
129 return result;
130 }
void Free(ClassTable *table)

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