Quote: "Normally you reserve memory with new or malloc/calloc. And this memory is freed with delete or free.
Every Agk function which returns a char* pointer reserves in this way a memory area for the string to be returned.
In the documentation it is written that this must be released with the function DeleteString.
instead of agk:: DeleteString(FileName) also delete [] FileName should work."
While to a degree you're right., because all BoldPaste2 is doing is creating Pointers (not Memory)... notice how it's a Direct Assignment, this actually means that the Allocated Memory is ONLY In-Flight during the Function; because it assume a Private (Local) Scope.
When the Function End then that Memory is no longer held by that Variable and the Application / OS will consider it "Free" Memory.
Allocation and Release of Memory is typically related to Scope unless you're manually doing it.
If you're not using "new" or "malloc( )"... then the Allocation only lasts for as long as the Variable does.
You have to remember A LOT of Reference Material is for C89 / C90 Compilers., and older Operating Systems; on top of this the assumption is that you're manually allocating Memory (and thus responsible for release as well).
As soon as you say "This Pointer is Null" the Operating System will say "Oh this Memory is no longer reserved... Mine!" but again ONLY if you haven't manually allocated it.
Of course you HAVE to be careful getting in the habit of this, and I wouldn't actually ever do this.
Instead leave it for the Operating System to clean up when the Application closes.
See the way you get Memory Leaks isn't from leaving Memory Allocated... but rather by removing all references to it.
Think about it like this... look at it like Coffee Cups at work.
Everyone has a Coffee or a Tea on their Break at work., so each person uses a Cup for that... now typically speaking everyone has a Cup that is "Theirs", at least for the Duration of Work... let's say it's common practise to put a sticker with your name on it during you shift.
Well; if this is done, then everyone on the later shift knows "Oh such-and-such is finished earlier, so I can clean this Cup and put my own name on it"; all is fine because you know what Cup are "In-Flight"
But there's ALWAYS that one person, who everytime they have a break just uses whatever Cup they want and peels off the sticker.
Well now you have a bunch of dirty cups, and NO idea whose they are.
That's essentially a Memory Leak. Eventually you're going to run out of Cups because NO ONE knows which are currently being used and which aren't.
Of course it would be the polite thing to do is take off the Sticker and Wash it up before you Leave; but let's say you have Kitchen Staff (Operating System) that will go around every few hours and clean up., well you get the point.
Do you understand what I mean?