In t2, any functions returning a char* will leak memory unless you delete the strings manually. Char* is just a pointer to some chars on the heap (or is it the stack) that does not get deleted automatically.
To safley clean the memory, you need to do something like this
char* ptr = agk::Str(); //Or any other function returning char*
//Do something with the string
delete[] ptr;
Also, make sure you don't delete a pointer that doesn't exist, it will cause a memory error and crash your program
You can solve that by doing this instead of just delete[]
if(ptr != NULL) //If the pointer isn't pointing at anything
{
delete[] ptr;
ptr = NULL; //Deleting what the pointer points at won't reset the pointer so you have to do this
}
Also, working with char* isn't such a good idea, you need to manage the memory and there are very few functions for doing anything. Using a string class is a better alternative. I would suggest using std::string, it's a standard and works really well. To use it with agk, you must first include the library by adding #include <string> to the top of the h file you want to use it in.
Then you can use it like this
std::string str;
char* ptr = agk::Str(); //You still need to delete the char*
str = ptr;
delete[] ptr;
//To use it in agk functions, you need to call .data on the string. .data returns a const char* with the same content as the string. Because it's const, you don't have to delete it
agk::LoadImage(str.data());
Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy