![]() |
libktx Reference 4.3.2
Libraries and tools to create and read KTX image texture files.
|
Implementation of ktxStream for memory. More...
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include "ktx.h"
#include "ktxint.h"
#include "memstream.h"
Macros | |
#define | KTX_MEM_DEFAULT_ALLOCATED_SIZE 256 |
Default allocation size for a ktxMemStream. | |
Functions | |
KTX_error_code | ktxMemStream_getdata (ktxStream *str, ktx_uint8_t **ppBytes) |
Get a pointer to a ktxMemStream's data. | |
void | ktxMemStream_setup (ktxStream *str) |
Setup ktxMemStream function pointers. | |
KTX_error_code | ktxMemStream_construct (ktxStream *str, ktx_bool_t freeOnDestruct) |
Initialize a read-write ktxMemStream. | |
KTX_error_code | ktxMemStream_construct_ro (ktxStream *str, const ktx_uint8_t *bytes, const ktx_size_t numBytes) |
Initialize a read-only ktxMemStream. | |
void | ktxMemStream_destruct (ktxStream *str) |
Free the memory used by a ktxMemStream. | |
Implementation of ktxStream for memory.
KTX_error_code ktxMemStream_construct | ( | ktxStream * | str, |
ktx_bool_t | freeOnDestruct | ||
) |
Initialize a read-write ktxMemStream.
Memory is allocated as data is written. The caller of this is responsible for freeing this memory unless freeOnDestruct is not KTX_FALSE.
[in] | str | pointer to a ktxStream struct to initialize. |
[in] | freeOnDestruct | If not KTX_FALSE memory holding the data will be freed by the destructor. |
KTX_INVALID_VALUE | str is NULL . |
KTX_OUT_OF_MEMORY | system failed to allocate sufficient memory. |
KTX_error_code ktxMemStream_construct_ro | ( | ktxStream * | str, |
const ktx_uint8_t * | bytes, | ||
const ktx_size_t | numBytes | ||
) |
Initialize a read-only ktxMemStream.
[in] | str | pointer to a ktxStream struct to initialize. |
[in] | bytes | pointer to an array of bytes containing the data. |
[in] | numBytes | size of array of data for ktxMemStream. |
KTX_INVALID_VALUE | str or mem is NULL or numBytes is 0. or size is less than 0. |
KTX_OUT_OF_MEMORY | system failed to allocate sufficient memory. |
void ktxMemStream_destruct | ( | ktxStream * | str | ) |
Free the memory used by a ktxMemStream.
This only frees the memory used to store the data written to the stream, if the freeOnDestruct
parameter to ktxMemStream_construct() was not KTX_FALSE
. Otherwise it is the responsibility of the caller of ktxMemStream_construct() and a pointer to this memory should be retrieved using ktxMemStream_getdata() before calling this function.
[in] | str | pointer to the ktxStream whose memory is to be freed. |
KTX_error_code ktxMemStream_getdata | ( | ktxStream * | str, |
ktx_uint8_t ** | ppBytes | ||
) |
Get a pointer to a ktxMemStream's data.
Gets a pointer to data that has been written to the stream. Returned pointer will be 0 if stream is read-only.
[in] | str | pointer to the ktxStream whose data pointer is to be queried. |
[in,out] | ppBytes | pointer to a variable in which the data pointer will be written. |
KTX_INVALID_VALUE | str or ppBytes is NULL . |