Re: RFC: glocal - automatically freeing memory when it goes out of scope
- From: Colin Walters <walters verbum org>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtk-devel-list <gtk-devel-list gnome org>, Alexander Larsson <alexl redhat com>
- Subject: Re: RFC: glocal - automatically freeing memory when it goes out of scope
- Date: Thu, 05 Apr 2012 13:21:01 -0400
On Thu, 2012-04-05 at 17:47 +0100, Chris Vine wrote:
> On Thu, 05 Apr 2012 10:58:24 -0400 (EDT)
> Alexander Larsson <alexl redhat com> wrote:
> [snip]
> > I might have been a bit sloppy with my words, but the following C++
> > code, in a shared library:
> >
> > MyClass my_object;
> >
> > Needs to have the MyClass constructor for the static object my_object
> > run before the main() function in your application. This is identical
> > to attribute constructor (in fact, implementation wise thats how this
> > works in C++).
>
> Ah, I understand you. And of course, if not in a shared library also.
There's also the fact that GLib's use of constructors is very local, and
if it really came to the point where one needed to make it work on some
old version of HP-UX or whatever, at worst one could hack up a patch
to just call the constructor code early in main() of whatever program
fairly easily.
Were we to make pervasive use of the cleanup attribute, then someone
attempting to remove the dependency would have to patch (in a nontrivial
way) *every function* that used it. It'd be a significant amount of
error-prone work.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]