KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
861 stars 225 forks source link

unclear how to free memory allocated in functions saying "caller is responsible for freeing it" #793

Closed AlexRouSg closed 10 months ago

AlexRouSg commented 10 months ago

So I noticed there are some functions that say "caller is responsible for freeing it" however it is not clear how is one supposed to free said memory, assuming it means literally calling free(), how would that work when libktx is built as a dynamic library?

Don't memory allocated within a dynamic library have to also be freed from within said dynamic library due to multiple instances of the C runtime and stuff?

MarkCallow commented 10 months ago

Don't memory allocated within a dynamic library have to also be freed from within said dynamic library due to multiple instances of the C runtime and stuff?

No. Shared libraries share code not data. Each process has its own global, heap and stack data. Call free() to free returned data. How would you like to see the documentation clarified?

AlexRouSg commented 10 months ago

I think I was just overthinking this cause I was used to seeing shared libs with a free function and was expecting to find one. I'll close the issue.