View Single Post
Re: Well , just a small question
Old
  (#9)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Well , just a small question - 26-12-2004

this
Code:
int iTask = pBot->pTasks->iTask;
returns a pointer to the iTask element in the structure pointed to by pTasks. But this code will crash if pTasks is NULL, i.e. points to no tasks structure. This however
Code:
int iTask = BotGetSafeTask (pBot)->iTask;
will always return a valid pTasks pointer (even if it points to an empty task structure, what I'd call a "failsafe pointer"). This way iTask is always guaranteed to be accessible and the code won't crash.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote