Apart from that DirectInput Memory "Caching" or memory leak IanM spoke of, there is another thing you need to take care of.
(bear in mind; I have not tested this. I could be wrong
)
You need to free the memory that has been allocated by the dbEntry() function. so, always after calling dbEntry and storing the result in your char pointer, you need to call free (my_ptr).
Of course only after you dont need the information anymore. AND of course only if it is NOT NULL.
so your code should look something like this (with a loop):
char* my_str = NULL;
while (expression) {
my_str = dbEntry();
if (my_str != NULL) {
//do somethin with the result (check also if not empty string).
// all is done, now free the memory
free (my_str);
}
}
hope this is correct and that it was helpful.
greets,
Barnski.
-- I just started with DarkSDK, by translating DBP Projects. --