* @~English * @brief Initialize a read-write ktxMemStream. * * Memory is allocated as data is written. The caller of this is * responsible for freeing this memory unless @a freeOnDestruct * is not KTX_FALSE. * * @param [in] str pointer to a ktxStream struct to initialize. * @param [in] freeOnDestruct If not KTX_FALSE memory holding the data will *
| 480 | * @exception KTX_OUT_OF_MEMORY system failed to allocate sufficient memory. |
| 481 | */ |
| 482 | KTX_error_code ktxMemStream_construct(ktxStream* str, |
| 483 | ktx_bool_t freeOnDestruct) |
| 484 | { |
| 485 | ktxMem* mem; |
| 486 | KTX_error_code result = KTX_SUCCESS; |
| 487 | |
| 488 | if (!str) |
| 489 | return KTX_INVALID_VALUE; |
| 490 | |
| 491 | result = ktxMem_create(&mem); |
| 492 | |
| 493 | if (KTX_SUCCESS == result) { |
| 494 | str->data.mem = mem; |
| 495 | ktxMemStream_setup(str); |
| 496 | str->closeOnDestruct = freeOnDestruct; |
| 497 | } |
| 498 | |
| 499 | return result; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * @~English |