You could create a function called MyLoadImage, which as well as loading the image and returning it from the function creates an instance of a type that also references that image. Then you could loop through all instances of that type and free the images when you need to clear everything out.
However, as GFK implied, you'd be far better off keeping track of what you have and haven't got loaded, freeing it as soon as you can and doing everything manually. It sounds like a lot of work, but if you start out doing this, your app will be better for it (in the least it will use the minimum of memory).
However, as GFK implied, you'd be far better off keeping track of what you have and haven't got loaded, freeing it as soon as you can and doing everything manually. It sounds like a lot of work, but if you start out doing this, your app will be better for it (in the least it will use the minimum of memory).