MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / ktxTexture2_constructCommon

Function ktxTexture2_constructCommon

lib/texture2.c:389–406  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

387 * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture data.
388 */
389static KTX_error_code
390ktxTexture2_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`.

Callers 2

ktxTexture2_constructFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected