.TH "lib/memstream.c" 3 "Sun Jun 14 2026 18:00:57" "Version 0.0.0" "libktx Reference" \" -*- nroff -*- .ad l .nh .SH NAME lib/memstream.c \- Implementation of \fBktxStream\fP for memory\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br \fR#include 'ktx\&.h'\fP .br \fR#include 'ktxint\&.h'\fP .br \fR#include 'memstream\&.h'\fP .br .SS "Macros" .in +1c .ti -1c .RI "#define \fBKTX_MEM_DEFAULT_ALLOCATED_SIZE\fP 256" .br .RI "Default allocation size for a ktxMemStream\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBKTX_error_code\fP \fBktxMemStream_getdata\fP (\fBktxStream\fP *str, ktx_uint8_t **ppBytes)" .br .RI "Get a pointer to a ktxMemStream's data\&. " .ti -1c .RI "void \fBktxMemStream_setup\fP (\fBktxStream\fP *str)" .br .RI "Setup ktxMemStream function pointers\&. " .ti -1c .RI "\fBKTX_error_code\fP \fBktxMemStream_construct\fP (\fBktxStream\fP *str, ktx_bool_t freeOnDestruct)" .br .RI "Initialize a read-write ktxMemStream\&. " .ti -1c .RI "\fBKTX_error_code\fP \fBktxMemStream_construct_ro\fP (\fBktxStream\fP *str, const ktx_uint8_t *bytes, const ktx_size_t numBytes)" .br .RI "Initialize a read-only ktxMemStream\&. " .ti -1c .RI "void \fBktxMemStream_destruct\fP (\fBktxStream\fP *str)" .br .RI "Free the memory used by a ktxMemStream\&. " .in -1c .SH "Detailed Description" .PP Implementation of \fBktxStream\fP for memory\&. .PP \fBAuthor\fP .RS 4 Maksim Kolesin, Under Development .PP Georg Kolling, Imagination Technology .PP Mark Callow, HI Corporation .RE .PP .SH "Function Documentation" .PP .SS "\fBKTX_error_code\fP ktxMemStream_construct (\fBktxStream\fP * str, ktx_bool_t freeOnDestruct)" .PP Initialize a read-write ktxMemStream\&. Memory is allocated as data is written\&. The caller of this is responsible for freeing this memory unless \fIfreeOnDestruct\fP is not KTX_FALSE\&. .PP \fBParameters\fP .RS 4 \fIstr\fP pointer to a \fBktxStream\fP struct to initialize\&. .br \fIfreeOnDestruct\fP If not KTX_FALSE memory holding the data will be freed by the destructor\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_INVALID_VALUE\fP\fP \fRstr\fP is \fRNULL\fP\&. .br \fI\fBKTX_OUT_OF_MEMORY\fP\fP system failed to allocate sufficient memory\&. .RE .PP .SS "\fBKTX_error_code\fP ktxMemStream_construct_ro (\fBktxStream\fP * str, const ktx_uint8_t * bytes, const ktx_size_t numBytes)" .PP Initialize a read-only ktxMemStream\&. .PP \fBParameters\fP .RS 4 \fIstr\fP pointer to a \fBktxStream\fP struct to initialize\&. .br \fIbytes\fP pointer to an array of bytes containing the data\&. .br \fInumBytes\fP size of array of data for ktxMemStream\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_INVALID_VALUE\fP\fP \fRstr\fP or \fRmem\fP is \fRNULL\fP or \fRnumBytes\fP is 0\&. or \fRsize\fP is less than 0\&. .br \fI\fBKTX_OUT_OF_MEMORY\fP\fP system failed to allocate sufficient memory\&. .RE .PP .SS "void ktxMemStream_destruct (\fBktxStream\fP * str)" .PP Free the memory used by a ktxMemStream\&. This only frees the memory used to store the data written to the stream, if the \fRfreeOnDestruct\fP parameter to \fBktxMemStream_construct()\fP was not \fRKTX_FALSE\fP\&. Otherwise it is the responsibility of the caller of \fBktxMemStream_construct()\fP and a pointer to this memory should be retrieved using \fBktxMemStream_getdata()\fP before calling this function\&. .PP \fBSee also\fP .RS 4 \fBktxMemStream_construct\fP, \fBktxMemStream_getdata\fP\&. .RE .PP \fBParameters\fP .RS 4 \fIstr\fP pointer to the \fBktxStream\fP whose memory is to be freed\&. .RE .PP .SS "\fBKTX_error_code\fP ktxMemStream_getdata (\fBktxStream\fP * str, ktx_uint8_t ** ppBytes)" .PP 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\&. .PP \fBParameters\fP .RS 4 \fIstr\fP pointer to the \fBktxStream\fP whose data pointer is to be queried\&. .br \fIppBytes\fP pointer to a variable in which the data pointer will be written\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_INVALID_VALUE\fP\fP \fRstr\fP or \fRppBytes\fP is \fRNULL\fP\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libktx Reference from the source code\&.