Silly String / memory Question
When I pass a string into a function as an argument such as,
Functionction("String");
Is this string handled in memory? Deleted when it is over (assuming it is being passed in as a char*) or does it create a memmory leak? I assume its cleared up for me automatically but I just want to make sure.
Ballistic Programs
Actually that string is static...the compiler creates space in your data segment (I think)...but it''s neither created or destroyed, it just exists...
so, in your function call...the compiler will push the address of that static variable on the stack, and call your function. The stack cleanup is handled for you, and so no memory leaks occur...
this wasn''t a stupid a question...I didn''t figure it out, till I started looking at the assembly...which I suggest you do
so, in your function call...the compiler will push the address of that static variable on the stack, and call your function. The stack cleanup is handled for you, and so no memory leaks occur...
this wasn''t a stupid a question...I didn''t figure it out, till I started looking at the assembly...which I suggest you do
Thanks for the quick reply, as for assembly, its on my list, just as soon as I finsh this IDE for MASM.
Ballistic Programs
Ballistic Programs
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement