__attribute__ ((cleanup) patch



Hi,

https://bugzilla.gnome.org/show_bug.cgi?id=685440

has a patch which just landed, but I wanted to give wider discussion to
this, because it's a very important infrastructural change.

First, one thing that came up is a concern about a GCC hard dependency.
My understanding is that LLVM implements this too.  For compilers which
implement C++, this is easy to support.  And since NetworkManager is
highly tied to Linux, it's not like we have to care about MSVC.

Now, I plan to do a followup patch pretty soon which would let us
get rid of a *lot* of g_free()/g_object_unref() calls.  By a
conservative estimate, around 1500 lines.

I've been using libgsystem cleanup extensively in several projects,
and it's been a massive win.

Other examples of projects using this in C are systemd and upstart.

The downside is that this is kind of a one-way door.  Once done, it'd be
immensely tedious to try to go back and add them again.  However, the
benefit to the code is huge, and even better - trust me, it makes
writing C fun again =)

So, thoughts?





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]