Crash when using GPtrArray with Dbus

Naveen Verma ernaveenverma at gmail.com
Wed Jul 29 04:17:48 PDT 2009


>
> gboolean
> downloadDaemonGetAllDownloads(DownloadDaemon* DaemonObject,
>                               GPtrArray** gptrAllDls,
>                               GError** error)
> {
>     GPtrArray* gptr_all_dls = g_ptr_array_sized_new(1);

-- You should directly initialize *gptrAIIDIs here, then add the member in
this, because the above gptr_all_dlls in stack and become out of scope after
this function call.


>
>     gptr_all_dls->len = numDls;

-- You don't need to set the length its dynamic array.

>
>
>      g_ptr_array_add(gptr_all_dls,(gpointer)(1234567));

-- you can use GUINT_TO_POINTER(123456)

>
>
>     *gptrAllDls = gptr_all_dls;
>
>     return TRUE;
> }
> -Br

Naveen


>
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20090729/838570f0/attachment.html 


More information about the dbus mailing list