|
From: | Paolo Bonzini |
Subject: | Re: [Help-smalltalk] gst_string_to_oop with local string |
Date: | Wed, 11 Nov 2009 10:37:20 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-3.9.b4.fc12 Lightning/1.0pre Thunderbird/3.0b4 |
On 11/11/2009 12:58 AM, Roland Plüss wrote:
char buffer[ 50 ]; sprintf( ( char* )&buffer, "(%f,%f,%f,%f)", csobject.color.r, csobject.color.g, csobject.color.b, csobject.color.a ); return gst_string_to_oop( buffer ); Returns garbage in smalltalk ( function returns OOP by the way and is mapped with #smalltalk as return value ). As I get from the documentation this function only "maps" the string and does not make a copy.
No, that's not true. I think you are overrunning the buffer (besides, (char*)&buffer is simply "buffer"). Try asprintf, like
char *buffer; asprintf (&buffer, ...); OOP stringOOP = gst_string_to_oop (buffer); free (buffer); return stringOOP; Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |