Am Montag, 22. M�rz 2004 11:59 schrieb Ashirus: > I testing out a program and one of the function uses a static pointer. The > pointer variable stores all the characters by the user, and has to maintain > this between function calls (the characters are then written to screen in > one truncated line). At the moment I have only allocated 100 bytes for it, > and haven't got round to checking the data doesn't overflow (I've just > started the program). > > Problem is, every time I recompile and load it into POSE, the variable's > data (i.e. all the characters entered) from the last compile is still there > and now exceeds 100 bytes and so crashes the program as soon as I enter a > new character! I don't know how POSE maintains this data, and I don't want > it! > > I know I could make sure the data my static pointer is pointing to get > initialised to NULL, but I want to know why this happens not how to solve > it.
Well - you really should initialize new menory you get, because the content is undefined. Undefined means that there may be anything inside - e.g. the data you wrote there the last time. The memory you free isn't cleared either and so it may happen that you get the same chunk you used last time. -- Mit freundlichen Gr��en Helmut A. Bender Helmut Bender GmbH -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
