I'm not sure if I'm missing something, or just reading into the paranoia about C++ and garbage collection too much.
Say I have the code below:
Since the function isn't returned to after calling 'unencode()', from what I gather the variable 'buf' will just stay there for as long as the OS allows it to. I assumed that would leak memory over time, but I can't seem to create that leak.Code:void f( int env_cl ) {char *buf = new char[env_cl]; for( int i=0; i<= env_cl && buf[i] != EOF; i++ ) { buf[i] = std::cin.get(); } buf[i] = 0x00; this->unencode( buf );}
I am missing something, right? You have to 'delete' each variable created on the free store don't you?
PS. I know using strings would solve this problem, but it would create others, not to mention the fact that I would still not know the answer.