> "Richard Burmeister" wrote:
> >> Char *phtxt, *ptxt;
> >> ptxt = "123456789";
> > ...
> From: Mark Smith
>
> There's nothing wrong with the code above. He doesn't need
> to allocate space for the string because it's static data.
> At a glance, I don't see anything obviously wrong the code
> that was posted.
>
Mark, you're right about it being ok to assign the pointer to static data,
since the data is allocated. So I took a closer look at his code and there
are several things wrong with it.
1. He never declares clen, plen, or phandle. phandle could be a big problem
since I'm not sure an int will correctly store a MemHandle.
2. hs is undefined. I assume it's something like:
Char hs[] = "0123456789ABCDEF";
3. There is no ";" at the end of "StrCopy(hextxt,htxt)" in hexdump, so this
couldn't possibly compile.
4. These statements in hexdump are wrong:
hextxt = (Char *)MemHandleLock((MemHandle)hexHandle);
StrCopy(hextxt,htxt);
hextxt has been passed in to hexdump as a locked pointer. So, I think he
should just do
StrCopy(hextxt,htxt);
5. Finally, using NULL for any of the params in FrmCustomAlert is bad if ^1,
^2, and ^3 all exist in the alert, which they must, given they way he calls
it with different params being null each time. You have to pass in " " (a
string with a single blank) for any params you don't want to use.
6. There could be more, but I don't have all day to fix his code...
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/