Re: Mixing of memory allocation methods with application
- From: Andreas Stricker <andreas stricker fela ch>
- To: gtk-app-devel-list gnome org
- Subject: Re: Mixing of memory allocation methods with application
- Date: Mon, 26 May 2008 13:07:29 +0200
Micah Carrick schrieb:
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.
I won't mix them, depending on circumstance, see below.
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);
I assume playlist->name was allocated by libmtp before?
This won't be a problem if you deallocate the structure and its content
yourself (even then it looks strange).
Is this going to cause problems? Should I make sure to use:
free (playlist->name);
playlist->name = strdup (new_name);
If the library frees the allocated playlist structure, this is right.
I would prefer the later one. The first one can easily lead to errors,
especially if the glib allocators don't use libc malloc implementation
sometime.
Cheers, Andy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]