ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::Allocator Class Referenceabstract

#include <flatbuffers.h>

Public Member Functions

virtual ~Allocator ()
 
virtual uint8_t * allocate (size_t size)=0
 
virtual void deallocate (uint8_t *p, size_t size)=0
 
virtual uint8_t * reallocate_downward (uint8_t *old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front)
 

Protected Member Functions

void memcpy_downward (uint8_t *old_p, size_t old_size, uint8_t *new_p, size_t new_size, size_t in_use_back, size_t in_use_front)
 

Detailed Description

Definition at line 677 of file flatbuffers.h.

Constructor & Destructor Documentation

◆ ~Allocator()

virtual flatbuffers::Allocator::~Allocator ( )
inlinevirtual

Definition at line 680 of file flatbuffers.h.

680{}

Member Function Documentation

◆ allocate()

virtual uint8_t * flatbuffers::Allocator::allocate ( size_t  size)
pure virtual

◆ deallocate()

virtual void flatbuffers::Allocator::deallocate ( uint8_t *  p,
size_t  size 
)
pure virtual

◆ memcpy_downward()

void flatbuffers::Allocator::memcpy_downward ( uint8_t *  old_p,
size_t  old_size,
uint8_t *  new_p,
size_t  new_size,
size_t  in_use_back,
size_t  in_use_front 
)
inlineprotected

Definition at line 708 of file flatbuffers.h.

710 {
711 memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back, in_use_back);
712 memcpy(new_p, old_p, in_use_front);
713 }

Referenced by reallocate_downward(), and flatbuffers::grpc::SliceAllocator::reallocate_downward().

◆ reallocate_downward()

virtual uint8_t * flatbuffers::Allocator::reallocate_downward ( uint8_t *  old_p,
size_t  old_size,
size_t  new_size,
size_t  in_use_back,
size_t  in_use_front 
)
inlinevirtual

Reimplemented in flatbuffers::grpc::SliceAllocator.

Definition at line 693 of file flatbuffers.h.

695 {
696 FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows
697 uint8_t *new_p = allocate(new_size);
698 memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, in_use_front);
699 deallocate(old_p, old_size);
700 return new_p;
701 }
#define FLATBUFFERS_ASSERT
Definition base.h:37
virtual uint8_t * allocate(size_t size)=0
virtual void deallocate(uint8_t *p, size_t size)=0
void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p, size_t new_size, size_t in_use_back, size_t in_use_front)

References allocate(), deallocate(), FLATBUFFERS_ASSERT, and memcpy_downward().

Referenced by flatbuffers::ReallocateDownward().


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