From fff98cc8f3bd3b0aebc3a95bcb1447dd82b27157 Mon Sep 17 00:00:00 2001 From: Matthew Rister Date: Mon, 17 Jun 2024 20:33:54 -0700 Subject: [PATCH] docs: clarify pointer lifetimes for ktxTexture_SetImageFromMemory 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. This commit adds a doxygen warning informing users that the underlying image data is copied and therefore they are responsible for their copy of the image memory. Closes #914 --- lib/writer1.c | 3 +++ lib/writer2.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/writer1.c b/lib/writer1.c index 8865e5634d..9ec29ce262 100644 --- a/lib/writer1.c +++ b/lib/writer1.c @@ -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. diff --git a/lib/writer2.c b/lib/writer2.c index cb41842e26..6a77fe4775 100644 --- a/lib/writer2.c +++ b/lib/writer2.c @@ -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.