[Gambas-devel] Store GB_VARIANT in memory
Tobias Boege
tobias at ...692...
Sat Aug 11 19:13:08 CEST 2012
Hi,
I want to save a GB_VARIANT into a buffer, Ref() the object inside, if any,
and return in later properly. My code looks something like this:
static void *val;
BEGIN_METHOD(Store, GB_VARIANT value)
/* Tried also GB_VARIANT here, but the error differs only, maybe
* because of the application... */
GB.Alloc(&val, sizeof(GB_VARIANT_VALUE));
GB.StoreVariant(ARG(value), val);
END_METHOD
BEGIN_METHOD_VOID(Restore)
GB.ReturnVariant(val);
GB.Free(&val);
END_METHOD
Suppose each Store() matches a Restore(), I get Segfaults in VALUE_write()
and since I don't quite look through Gambas datatype and storage (yesterday
crusaded against object reference counting successfully, though) I thought
it's simpler to ask directly - the array types were not really helpful to
me as I could not get to the exact point where memory allocation takes
place. Or, if I were there (ARRAY_add_data()?), I didn't get it.
BTW, the above is clearly simplified, I need allocating val dynamically.
Regards,
Tobi
More information about the Devel
mailing list