Mixing of memory allocation methods with application
- From: Micah Carrick <email micahcarrick com>
- To: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Mixing of memory allocation methods with application
- Date: Sun, 25 May 2008 12:21:00 -0700
I have a GTK application which is working with a C library (Libmtp).
This C library uses standard C functions such as free, malloc, strndup, etc.
When I am working with a structure from this library, I should be using
those same functions on those structures right? Because *my* parts of my
application (elsewhere) are using the g_xxxx functions.
For example, right now I have a structure coming from Libmtp for
playlists. When renaming that playlist I used:
free (playlist->name);
playlist->name = g_strdup (new_name);
Is this going to cause problems? Should I make sure to use:
free (playlist->name);
playlist->name = strdup (new_name);
Also, these structures have arrays of tracks (uint32_t*). I have some
routines which replace that array with the 'data' member of a GArray...
that's probably *bad* since GArray doesn't use regular malloc()... right?
--
- Micah Carrick
Developer - http://www.micahcarrick.com
GTK+ Forums - http://www.gtkforums.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]