>
>is a common construction, but in the memory limited environment of
>Palm OS probably too sloppy -- there's no way to guarantee that the
>stack has the 100 bytes available when you ask for it, and since
>dynamic memory is pretty small, there a good chance that it won't.
>
>This is the whole reason the PalmOS offers locked chunks.  This
>guarantees a safe piece of memory for manipulation.  In my
>experience, the only route to truly reliable code in PalmOS is to
>explicitly allocate every byte and explicitly deallocate it when
>you're done.  It's a pain in the butt, but I find it oddly satisfying
>to watch my program not leak any memory at all...
>
>Hence:
>
>VoidHand       h;
>CharPtr        c;
>
>h=MemHandleNew(pick_your_size);
>c=MemHandleLock(h);
>
>StrCopy(c,"blah blah blah");
>
>MemHandleUnlock(h);
>MemHandleFree(h);

Youch! Without error checking, I'd say that is worse than:

>boo[100];
>
>StrCopy(boo,"blah");

Ideally you should both do error checking (handle the case where h == NULL
after MemHandleNew), AND use StrNCopy.

Brian
_____________________________________________________________________
Mark/Space Softworks                               voice 408-293-7299
111 West Saint John, 3rd Floor                       fax 408-293-7298
San Jose, CA 95113                         <http://www.markspace.com>

        PalmOS, Mac OS, Windows and Web Software & Solutions:

         PageNOW! Wireless Messaging, PhoneWatcher Caller ID,
                   Fax Send and Receive for PalmOS
     Online & Communicate terminal emulation and serial debugging
          DataCord serial data cables for Handheld Devices


-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to