All (or many) of the functions in DarkGDK that return a char* allocate new memory on each call.
That includes:
dbStr
dbInput
dbEntry
dbGetEntry
dbLeft
etc...
Usage is as follows:
char* ptr = db___();
// Use ptr here
delete[] ptr;
If you don't assign the returned
pointer to a variable, you lose the address, and the newly allocated memory gets thrown onto and forgotten on the heap. It may seem harmless that a few bytes of memory get left behind, but if you call one of these functions wrong in every loop, the garbage can accumulate, and eventually crash the program or the computer.
As for the file input commands, they are only in the gdk since the gdk is almost a direct port of dbc, which included the original functions. That's why people just say to use fstream. It just gives more control over files, and why not use native C++ functions when using C++?
"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips