On 22.02.2007 19:10, Mildred wrote:
> - Why the string is not constant ?

Possibly sloppy programming/design.

> - If I call this method twice, can I discard the first string the
>   second time ?
> 
> The problem I have is that i get this string from a lua script. Lua
> ensure me that the string still exists until the end of the current
> function. So I think I need to copy the string on the heap, involving a
> new[] or a malloc. But then I wonder when I should free this memory (I
> suppose in the csApplicationFramework destructor). And because the lua
> script can call this function many times, I wonder if I just can
> discard the string that was previously allocated.

csApplicationFramework just stores the provided pointer to the string,
so some sort of copy has to be made. (I guess the assumption was that
the application ID isn't dynamic, so the pointer would be to a
compile-time constant string, so a copy wouldn't be necessary.)
I think it should be safe to discard the string previously allocated...
csApplicationFramework is certainly safe in that regard. For other code
that may query the application ID ... you'll probably notice if that
isn't. The proper way to deal with the application ID is to use
GetApplicationName() every time anyway.

-f.r.

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to