--- In [EMAIL PROTECTED], "Todd C. Johnson" <[EMAIL PROTECTED]> wrote:
> When I execute the following code, I get an error saying:
> "ServiceTime just wrote to memory location 0x000026B7, which is in
> Memory Manager data structures."
>
> What am I doing wrong?
>
<SNIP/>
> static FieldPtr SetFieldTextFromPtr(UInt16 fieldID, Char* newstrP)
> {
> MemHandle txtH;
> char *str;
>
> // get some space in which to stash the string
> txtH = MemHandleNew(StrLen(newstrP + 1));
Here's your problem: "(StrLen(newstrP + 1))"
This should be: "(StrLen(newstrP) + 1)"
The way you're doing it will give the length of the string starting at the
second character, rather than the length of the string plus one for the null
terminator.
> if (!txtH)
> return NULL;
>
> // copy the string to the locked handle
> str =MemHandleLock(txtH);
> StrCopy(str, newstrP);
>
> // Unlock the string handle
> MemHandleUnlock(txtH);
>
> // set the field to the handle
> return SetFieldTextFromHandle(fieldID,txtH);
>
> }
<SNIP/>
Cheers
Russell
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/