Thread: Finding leaks
View Single Post
Re: Finding leaks
Old
  (#2)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Finding leaks - 18-02-2005

mostly its with indexes. Ie:

Code:
 
int test[10];
 
for (int i=0; i < 10; i++)
 test[i]=-1;
 
// and this is bad
test[i] = 0; // means i = 10 , ouch
Or simply having a bigger content in a char then possible:

Code:
 
char msg[10];
// this 11 characters + carriage return! (so needs 12)
sprintf(msg, "Hello world\n");
its within all these little obvious things. Easy to overlook. Perhaps you can use assert to track down suspecious variables.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote