I am implementing a DBUS object with Glib bindings and am having problems with returning GArrays:
gboolean TestObject_get_data(TestObject* obj, GArray* buffer, GError** error)
{
int i;
printf("%s Entering\n", __PRETTY_FUNCTION__);
buffer = g_array_new(FALSE, FALSE, sizeof(char));
if(buffer)
{
for(i = 0; i < 5 ; i++)
{
g_array_append_val(buffer, i);
}
return TRUE;
}
/* TODO: Error handling */
return FALSE;
}
When I call the object's method with a test client, I get a segmentation fault:
waffleman@thegriddle$ ./testObject
TestObject_get_data Entering
** ERROR **: out of memory
aborting...
Aborted (core dumped)
The program crashes after the function returns. This is the first time I've ever used Glib, so there may be something obvious that I am missing. I have been reading this tutorial, and most of the examples works. Unfortunately it does not have an example for returning an array to the client.