Loading...
Searching...
No Matches
CAPI_Buffer.h File Reference

Overview

A fixed-size container for raw byte data.

#include <Ultralight/CAPI/CAPI_Buffer.h>

This class is used to represent raw data buffers in Ultralight. It intelligently manages the lifetime of the data and can optionally call a user-supplied callback to deallocate the data when the Buffer is destroyed.

Functions

ULExport ULBuffer ulCreateBuffer (void *data, size_t size, void *user_data, ulDestroyBufferCallback destruction_callback)
 Create a Buffer from existing, user-owned data without any copies.
 
ULExport ULBuffer ulCreateBufferFromCopy (const void *data, size_t size)
 Create a Buffer from existing data, a deep copy of data will be made.
 
ULExport void ulDestroyBuffer (ULBuffer buffer)
 Destroy buffer (you should destroy any buffers you explicitly Create).
 
ULExport void * ulBufferGetData (ULBuffer buffer)
 Get a pointer to the raw byte data.
 
ULExport size_t ulBufferGetSize (ULBuffer buffer)
 Get the size in bytes.
 
ULExport void * ulBufferGetUserData (ULBuffer buffer)
 Get the user data associated with this Buffer, if any.
 
ULExport bool ulBufferOwnsData (ULBuffer buffer)
 Check whether this Buffer owns its own data (Buffer was created via ulCreateBufferFromCopy).
 

Typedefs

typedef void(* ulDestroyBufferCallback) (void *user_data, void *data)
 

Function Documentation

◆ ulBufferGetData()

ULExport void * ulBufferGetData ( ULBuffer buffer)

Get a pointer to the raw byte data.

◆ ulBufferGetSize()

ULExport size_t ulBufferGetSize ( ULBuffer buffer)

Get the size in bytes.

◆ ulBufferGetUserData()

ULExport void * ulBufferGetUserData ( ULBuffer buffer)

Get the user data associated with this Buffer, if any.

◆ ulBufferOwnsData()

ULExport bool ulBufferOwnsData ( ULBuffer buffer)

Check whether this Buffer owns its own data (Buffer was created via ulCreateBufferFromCopy).

If this is false, Buffer will call the user-supplied destruction callback to deallocate data when this Buffer instance is destroyed.

◆ ulCreateBuffer()

ULExport ULBuffer ulCreateBuffer ( void * data,
size_t size,
void * user_data,
ulDestroyBufferCallback destruction_callback )

Create a Buffer from existing, user-owned data without any copies.

An optional, user-supplied callback will be called to deallocate data upon destruction.

Parameters
dataA pointer to the data.
sizeSize of the data in bytes.
user_dataOptional user data that will be passed to destruction_callback when the returned Buffer is destroyed.
destruction_callbackOptional callback that will be called upon destruction. Pass a null pointer if you don't want to be informed of destruction.

◆ ulCreateBufferFromCopy()

ULExport ULBuffer ulCreateBufferFromCopy ( const void * data,
size_t size )

Create a Buffer from existing data, a deep copy of data will be made.

◆ ulDestroyBuffer()

ULExport void ulDestroyBuffer ( ULBuffer buffer)

Destroy buffer (you should destroy any buffers you explicitly Create).

Typedef Documentation

◆ ulDestroyBufferCallback

typedef void(* ulDestroyBufferCallback) (void *user_data, void *data)

Go to the source code of this file.