On Tue, May 09, 2023 at 11:42:30AM -0400, Ralph Siemsen wrote:
On Tue, May 09, 2023 at 04:52:45PM +0200, Marek Vasut wrote:
Do we have some sort of global (?) state structure which exists
during the whole work cycle of the tool ? If so, add a link list
into there.
There is struct image_tool_params which is passed to the callbacks and
holds most of the state. And in fact it is a global, but declared
static in mkimage.c, without any accessor function.
If we really want to worry about the lifecycle of these dynamic
allocations, then we'd probably need to add some kind of "cleanup"
method to the API, and call it right before exiting from main().
I can do an example implementation, but there are 9 other image
formats already in the tree, which also do dynamic allocation. I don't
want to start touching each one of those, or I'll never get this RZ/N1
in...
I'll keep the current logic (which leaks) and send a separate RFC patch
to discuss a strategy for fixing this in all the tools/*image.c drivers.
Ralph