It would probably be good if you told us what problems you are having.  but
if charsP is a pre-existing string that you want to copy, you would need to
do:

MemPtrNew(sizeof(Char) * (StrLen(charsP) + 1))

The '+1' is for the null at the end of the string.

Best,
Colin
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kerry
Twibell
Sent: Wednesday, October 01, 2003 1:27 PM
To: Palm Developer Forum
Subject: Allocating memory for Char strings - MemPtrNew(StrLen(charsP))?

I'm having problems re: allocating memory for dynamic strings. My
application does a lot of string parsing, and I don't know how large strings
will be in advance.


I've been using the function
"MemPtrNew(StrLen(charsP)) - this way, I don't allocate too much or too
little memory. Is this the correct way to allocate memory for Char strings?
I've tried "MemPtrNew(sizeof(charsP)),"
"MemPtrnew(sizeof(*charsP))" and
"MemPtrNew(*charsP)," but all seem to fail.


=====
Kerry L. Twibell
Computer Systems Engineer
[EMAIL PROTECTED]

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


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

Reply via email to