Skip to content

Commit

Permalink
docs: clarify pointer lifetimes for ktxTexture_SetImageFromMemory (#917)
Browse files Browse the repository at this point in the history
**Problem** 
`ktxTexture1_SetImageFromMemory` and `ktxTexture2_SetImageFromMemory`
accept a pointer to image memory but do not clearly document if
ownership of those pointers is transferred or copied.

**Solution**
This commit adds a Doxygen note informing users that the underlying
image data is copied and that they are responsible for freeing the
original copy of image memory.

**Testing**
Documentation updates were manually verified by building the project
using the `KTX_FEATURE_DOC=ON` CMake option and viewing the generated
Doxygen output using a local server.

Closes #914
  • Loading branch information
matthew-rister authored Jun 18, 2024
1 parent b6cee11 commit b2cad1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/writer1.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level,
*
* @warning Do not use @c memcpy for this as it will not pad when necessary.
*
* @note The caller is responsible for freeing the original image memory
* referred to by @p src.
*
* @param[in] This pointer to the target ktxTexture object.
* @param[in] level mip level of the image to set.
* @param[in] layer array layer of the image to set.
Expand Down
3 changes: 3 additions & 0 deletions lib/writer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level,
* Level, layer, faceSlice rather than offset are specified to enable some
* validation.
*
* @note The caller is responsible for freeing the original image memory
* referred to by @p src.
*
* @param[in] This pointer to the target ktxTexture object.
* @param[in] level mip level of the image to set.
* @param[in] layer array layer of the image to set.
Expand Down

0 comments on commit b2cad1a

Please sign in to comment.