* @memberof ktxTexture2 @private * @~English * @brief Do the part of ktxTexture2 construction that is common to * new textures and those constructed from a stream. * * @param[in] This pointer to a ktxTexture2-sized block of memory to * initialize. * @param[in] numLevels the number of levels the texture must have. * * @return KTX_SUCCESS on success, othe
| 387 | * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture data. |
| 388 | */ |
| 389 | static KTX_error_code |
| 390 | ktxTexture2_constructCommon(ktxTexture2* This, ktx_uint32_t numLevels) |
| 391 | { |
| 392 | assert(This != NULL); |
| 393 | ktx_size_t privateSize; |
| 394 | |
| 395 | This->classId = ktxTexture2_c; |
| 396 | This->vtbl = &ktxTexture2_vtbl; |
| 397 | This->_protected->_vtbl = ktxTexture2_vtblInt; |
| 398 | privateSize = sizeof(ktxTexture2_private) |
| 399 | + sizeof(ktxLevelIndexEntry) * (numLevels - 1); |
| 400 | This->_private = (ktxTexture2_private*)malloc(privateSize); |
| 401 | if (This->_private == NULL) { |
| 402 | return KTX_OUT_OF_MEMORY; |
| 403 | } |
| 404 | memset(This->_private, 0, privateSize); |
| 405 | return KTX_SUCCESS; |
| 406 | } |
| 407 | |
| 408 | /* |
| 409 | * In hindsight this function should have been `#if KTX_FEATURE_WRITE`. |
no test coverage detected