On 2005-05-04, Scott Erickson <[EMAIL PROTECTED]> wrote:
> Henk,
>     Could this be the reason... I have a struct to hold my app settings.  I 
> make one declaration of that to be global.  In appstart i allocate memory 
> for it with memptrnew and a temporary memprt.  then i use in in many 
> functions with no problems.  then in appstop i try to free the memory with 
> MemPtrFree(currentSettings);  yet the simulator tells me i have an unfreed 
> chunk (same as the value of the pointer to the variable), and the device 
> softresets at this point.  how can i free the chunk of mem i am using for 
> this variable?  below is some relavent code from my app...
>
> (the declaration is above all function calls, but below all function 
> headers)
>  typedef struct{
>   Boolean monitor;
>   UInt32 aUpdate;
>   Char* lastUpdate;
>   Char* license;
>  } appSettings;
> appSettings *currentSettings;
>
> (in appstart)
> MemPtr temp;
>  UInt16 appSettingsSize;
>  appSettingsSize = sizeof(currentSettings);
                            ^^^^^^^^^^^^^^^
This is wrong. sizeof(currentSettings) is 4 since currentSettings is a 
pointer. I guess you mean sizeof(appSettings) instead.
Hence your allocated memory is too small and you are overwriting other
memory.   

>  temp = MemPtrNew(appSettingsSize);
>  currentSettings = temp;
>
> (in appstop)
> MemPtrFree(currentSettings);
>

Ton van Overbeek

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to