It would be nice to know what sort of errors you're running into.
You may have a few problems...
you don't check the return value from
a = MemPtrNew(10);
you don't check for (a == NULL) before you
len = StrLen(a);
there are some (non default) compiler settings which make
StrCopy(a,"dinesh");
fail if globals aren't available.
--Adam
Dinesh wrote:
> hi all,
>
> In the follwing code i am not able to duplicate a string.
> Do you find any problems with this code ?
> Please guide me.
>
> regards,
> Dinesh.
>
> char * strdup(char *a)
> {
> UInt16 len;
> char *b;
>
> len = StrLen(a);
> if ( (b = MemPtrNew( len + 1 )) == NULL )
> return( NULL );
> StrCopy(b,a);
> return(b);
> }
>
> Boolean IvoxFormHandleEvent(EventPtr event)
> {
> ...
> ....
> switch (event->eType) {
> case ctlSelectEvent: // A control button was pressed and released.
> if (event->data.ctlSelect.controlID == MainRecordButton)
> {
> char *a;
> char *b;
> a = MemPtrNew(10);
> StrCopy(a,"dinesh");
> b = strdup(a);
> MemPtrFree(a);
> MemPtrFree(b);
> }
> ...
> ...
> }
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see
>http://www.palmos.com/dev/tech/support/forums/
--
Adam Wozniak Senior Software Design Engineer
Surveyor Corporation
[EMAIL PROTECTED] 4548 Broad Street
[EMAIL PROTECTED] San Luis Obispo, CA 93401
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/