After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761959 - [review] cleanup event_handler_recvmsgs() in nm-linux-platform.h [th/platform-recvmsgs-fixes-bgo761959]
[review] cleanup event_handler_recvmsgs() in nm-linux-platform.h [th/platform...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-02-12 15:46 UTC by Thomas Haller
Modified: 2016-02-16 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Haller 2016-02-12 15:46:42 UTC
please review
Comment 1 Beniamino Galvani 2016-02-16 13:04:15 UTC
> macros: add nm_auto_free macro

  Similar to gs_free to cleanup pointers with free(). Note that
  g_free() and free() cannot be used interchangably.

I don't understand which is the practical difference between gs_free()
and nm_auto_free(), can you please explain?

The rest LGTM.
Comment 2 Thomas Haller 2016-02-16 13:14:10 UTC
In many cases g_free/g_malloc uses free/malloc from libc and there is no difference.

That is however not guaranteed and where it's not true, bad things will happen.


Thus, if memory was allocated with malloc(), you must free it with free() or nm_auto_free -- not g_free() nor gs_free.


See also:
https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html


It's important to match g_malloc() (and wrappers such as g_new()) with g_free(), g_slice_alloc() (and wrappers such as g_slice_new()) with g_slice_free(), plain malloc() with free(), and (if you're using C++) new with delete and new[] with delete[]. Otherwise bad things can happen, since these allocators may use different memory pools (and new/delete call constructors and destructors).