You forgot to test myHandle and make sure it points to valid data when
MemHandleNew returns.  1300 bytes is a rather big chunk of memory for such a
small device.  After you begin to fragment memory, the possibility exists
that you might not be able to allocate that large of a chunk (it will also
depend on which version of the OS your app is running on).

----- Original Message -----
From: "Scott Brooks" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 2:49 PM
Subject: Re: Invalid Handle CRAZINESS


> I guess I'll go ahead and reply to my own message:
>
> I changed the Handle LENGTH to 1300 and it crashed after only a couple
> records.  Then I added MemHandleFree(myHandle) and I went through the
whole
> list about 8 times and it hasn't crashed yet.
>
> Now, all my code that has to do with that Handle looks like:
>
>      MemHandle  myHandle = MemHandleNew(1300);
>      Char       *myText  = MemHandleLock(myHandle);
>
>      ...string operations...
>
>      MemHandleUnlock(myHandle);
>      MemHandleFree(myHandle);
>
> Is there anything else I need to free or anything before my function ends.
>
> I actually went through a tutorial a month ago and never saw the use of
> MemHandleFree().  It only took about 50 pages of code and prob'ly a few
> hundred calls to MemHandleNew for it to finally cause it to crash.
>
> If anyone notices anything I am missing or perhaps thinks this was a
fluke,
> your comments would be appreciated.
>
> Thanks,
> Scott
>




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

Reply via email to