Nope, this is a new question from you :-)
All of the NewString*() APIs copy the source data into an ooRexx
String object. It does nothing with the storage you point it to
except copy the data out of it, so it doesn't really matter how the
storage was created. If you allocated the storage, then you're
responsible for releasing it.
There's one additional option available, but that needs to be used
with care. There's an additional API called NewBufferString(). This
creates what's essentially an "empty" string object into which you can
obtain a data pointer and copy information into the string. This is
useful for things like charin(), since I can allocate the result
string, then read the data directly into the result object, skipping
the need to use an intermediate buffer. Generally, this is useful if
you know the upper bound of the data you're going to construct. If
you use this option, it is vitally important to call
FinishBufferString() with the final result length (which can be
shorter than your initial allocation size, but not larger).
Generally, for most uses, it is better to directly create the string
object using the normal APIs.
Rick
On Sat, Aug 2, 2008 at 5:47 PM, Mark Miesfeld <[EMAIL PROTECTED]> wrote:
> I'm not clear on this, thought I should get some confirmation.
>
> With context->NewStringFromAsciiz() I've been assuming the
> interperter makes a copy of the string, so it is okay to use local
> storage
>
> RexxMethod1(..)
> {
> char buffer[64];
> ...
> return context->NewStringFromAsciiz(buffer);
> }
>
> Or if I malloc'd storage for the string, I would free it:
>
> RexxMethod1(..)
> {
> char *buffer = (char *)malloc(64);
> ...
> RexxStringObject result = context->NewStringFromAsciiz(buffer);
> free(buffer);
> return result;
> }
>
> Is that correct? And, is it also true with context->NewString()?
>
> Seems to me I've asked this before, and I don't remember the answer. ;-(
>
> Should I be, (on Windows,) using GlobalAlloc for strings that I pass
> to context->NewString() or context->NewStringFromAsciiz() and leave it
> to the interpreter to free the memory?
>
> --
> Confused in San Diego
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Oorexx-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel