Flutter Engine
The Flutter Engine
Public Member Functions | Private Member Functions | List of all members
dart::MallocWriteStream Class Reference

#include <datastream.h>

Inheritance diagram for dart::MallocWriteStream:
dart::NonStreamingWriteStream dart::BaseWriteStream dart::ValueObject

Public Member Functions

 MallocWriteStream (intptr_t initial_size)
 
 ~MallocWriteStream ()
 
uint8_t * Steal (intptr_t *length)
 
- Public Member Functions inherited from dart::NonStreamingWriteStream
 NonStreamingWriteStream (intptr_t initial_size)
 
uint8_t * buffer () const
 
DART_FORCE_INLINE void SetPosition (intptr_t value)
 
- Public Member Functions inherited from dart::BaseWriteStream
 BaseWriteStream (intptr_t initial_size)
 
virtual ~BaseWriteStream ()
 
DART_FORCE_INLINE intptr_t bytes_written () const
 
virtual intptr_t Position () const
 
intptr_t Align (intptr_t alignment, intptr_t offset=0)
 
void WriteWordWith32BitWrites (uword value)
 
template<typename T >
void WriteUnsigned (T value)
 
void WriteRefId (intptr_t value)
 
void WriteBytes (const void *addr, intptr_t len)
 
void WriteWord (uword value)
 
void WriteTargetWord (word value)
 
void Printf (const char *format,...) PRINTF_ATTRIBUTE(2
 
void va_start (args, format)
 
 VPrintf (format, args)
 
 va_end (args)
 
void VPrintf (const char *format, va_list args)
 
template<typename T >
void Write (T value)
 
template<typename T >
void WriteFixed (T value)
 
DART_FORCE_INLINE void WriteByte (uint8_t value)
 
void WriteString (const char *cstr)
 
template<typename T >
C::only_if_unsigned< T, void > WriteLEB128 (T value)
 
template<typename T >
C::only_if_signed< T, void > WriteLEB128 (T value)
 
template<typename T >
C::only_if_signed< T, void > WriteSLEB128 (T value)
 
template<typename T >
C::only_if_unsigned< T, void > WriteSLEB128 (T value)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Private Member Functions

virtual void Realloc (intptr_t new_size)
 

Additional Inherited Members

- Protected Member Functions inherited from dart::BaseWriteStream
void EnsureSpace (intptr_t size_needed)
 
virtual void SetPosition (intptr_t value)
 
DART_FORCE_INLINE intptr_t Remaining () const
 
virtual void Realloc (intptr_t new_capacity)=0
 
 DISALLOW_COPY_AND_ASSIGN (BaseWriteStream)
 
- Protected Attributes inherited from dart::BaseWriteStream
const intptr_t initial_size_
 
uint8_t * buffer_ = nullptr
 
uint8_t * current_ = nullptr
 
intptr_t capacity_ = 0
 

Detailed Description

Definition at line 625 of file datastream.h.

Constructor & Destructor Documentation

◆ MallocWriteStream()

dart::MallocWriteStream::MallocWriteStream ( intptr_t  initial_size)
inlineexplicit

Definition at line 627 of file datastream.h.

628 : NonStreamingWriteStream(initial_size) {}
NonStreamingWriteStream(intptr_t initial_size)
Definition: datastream.h:611

◆ ~MallocWriteStream()

dart::MallocWriteStream::~MallocWriteStream ( )

Definition at line 17 of file datastream.cc.

17 {
18 free(buffer_);
19}

Member Function Documentation

◆ Realloc()

void dart::MallocWriteStream::Realloc ( intptr_t  new_size)
privatevirtual

Implements dart::BaseWriteStream.

Definition at line 21 of file datastream.cc.

21 {
22 const intptr_t old_offset = current_ - buffer_;
23 buffer_ = reinterpret_cast<uint8_t*>(realloc(buffer_, new_size));
24 capacity_ = buffer_ != nullptr ? new_size : 0;
25 current_ = buffer_ != nullptr ? buffer_ + old_offset : nullptr;
26}
void * realloc(void *ptr, size_t size)
Definition: allocation.cc:27

◆ Steal()

uint8_t * dart::MallocWriteStream::Steal ( intptr_t *  length)
inline

Definition at line 633 of file datastream.h.

633 {
634 ASSERT(length != nullptr);
636 uint8_t* const old_buffer = buffer_;
637 // We don't immediately reallocate a new space just in case this steal
638 // is the last use of this stream.
639 current_ = buffer_ = nullptr;
640 capacity_ = 0;
641 return old_buffer;
642 }
DART_FORCE_INLINE intptr_t bytes_written() const
Definition: datastream.h:338
#define ASSERT(E)
size_t length

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