Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skia_private::AutoTMalloc< T, typename > Class Template Reference

#include <SkTemplates.h>

Public Member Functions

 AutoTMalloc (T *ptr=nullptr)
 
 AutoTMalloc (size_t count)
 
 AutoTMalloc (AutoTMalloc &&)=default
 
AutoTMallocoperator= (AutoTMalloc &&)=default
 
void realloc (size_t count)
 
Treset (size_t count=0)
 
Tget () const
 
 operator T* ()
 
 operator const T * () const
 
Toperator[] (int index)
 
const Toperator[] (int index) const
 
const Tdata () const
 
Tdata ()
 
Trelease ()
 

Detailed Description

template<typename T, typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
class skia_private::AutoTMalloc< T, typename >

Manages an array of T elements, freeing the array in the destructor. Does NOT call any constructors/destructors on T (T must be POD).

Definition at line 278 of file SkTemplates.h.

Constructor & Destructor Documentation

◆ AutoTMalloc() [1/3]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
skia_private::AutoTMalloc< T, typename >::AutoTMalloc ( T ptr = nullptr)
inlineexplicit

Takes ownership of the ptr. The ptr must be a value which can be passed to sk_free.

Definition at line 281 of file SkTemplates.h.

281: fPtr(ptr) {}

◆ AutoTMalloc() [2/3]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
skia_private::AutoTMalloc< T, typename >::AutoTMalloc ( size_t  count)
inlineexplicit

Allocates space for 'count' Ts.

Definition at line 284 of file SkTemplates.h.

285 : fPtr(count ? (T*)sk_malloc_throw(count, sizeof(T)) : nullptr) {}
int count
static void * sk_malloc_throw(size_t size)
Definition SkMalloc.h:67
#define T

◆ AutoTMalloc() [3/3]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
skia_private::AutoTMalloc< T, typename >::AutoTMalloc ( AutoTMalloc< T, typename > &&  )
default

Member Function Documentation

◆ data() [1/2]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
T * skia_private::AutoTMalloc< T, typename >::data ( )
inline

Definition at line 313 of file SkTemplates.h.

313{ return fPtr.get(); }

◆ data() [2/2]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
const T * skia_private::AutoTMalloc< T, typename >::data ( ) const
inline

Aliases matching other types, like std::vector.

Definition at line 312 of file SkTemplates.h.

312{ return fPtr.get(); }

◆ get()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
T * skia_private::AutoTMalloc< T, typename >::get ( ) const
inline

Definition at line 301 of file SkTemplates.h.

301{ return fPtr.get(); }

◆ operator const T *()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
skia_private::AutoTMalloc< T, typename >::operator const T * ( ) const
inline

Definition at line 305 of file SkTemplates.h.

305{ return fPtr.get(); }

◆ operator T*()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
skia_private::AutoTMalloc< T, typename >::operator T* ( )
inline

Definition at line 303 of file SkTemplates.h.

303{ return fPtr.get(); }

◆ operator=()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
AutoTMalloc & skia_private::AutoTMalloc< T, typename >::operator= ( AutoTMalloc< T, typename > &&  )
default

◆ operator[]() [1/2]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
T & skia_private::AutoTMalloc< T, typename >::operator[] ( int  index)
inline

Definition at line 307 of file SkTemplates.h.

307{ return fPtr.get()[index]; }

◆ operator[]() [2/2]

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
const T & skia_private::AutoTMalloc< T, typename >::operator[] ( int  index) const
inline

Definition at line 309 of file SkTemplates.h.

309{ return fPtr.get()[index]; }

◆ realloc()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
void skia_private::AutoTMalloc< T, typename >::realloc ( size_t  count)
inline

Resize the memory area pointed to by the current ptr preserving contents.

Definition at line 291 of file SkTemplates.h.

291 {
292 fPtr.reset(count ? (T*)sk_realloc_throw(fPtr.release(), count * sizeof(T)) : nullptr);
293 }
SK_API void * sk_realloc_throw(void *buffer, size_t size)

◆ release()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
T * skia_private::AutoTMalloc< T, typename >::release ( )
inline

Transfer ownership of the ptr to the caller, setting the internal pointer to NULL. Note that this differs from get(), which also returns the pointer, but it does not transfer ownership.

Definition at line 320 of file SkTemplates.h.

320{ return fPtr.release(); }

◆ reset()

template<typename T , typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value && std::is_trivially_destructible<T>::value>>
T * skia_private::AutoTMalloc< T, typename >::reset ( size_t  count = 0)
inline

Resize the memory area pointed to by the current ptr without preserving contents.

Definition at line 296 of file SkTemplates.h.

296 {
297 fPtr.reset(count ? (T*)sk_malloc_throw(count, sizeof(T)) : nullptr);
298 return this->get();
299 }

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