bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#22737: 25.1; Finalizer should be optional in dynamic modules


From: Jess Balint
Subject: bug#22737: 25.1; Finalizer should be optional in dynamic modules
Date: Tue, 23 Feb 2016 16:47:12 -0600

If the data is unspecified it doesn't *necessarily* need to be freed. If I return a pointer to some global data then I need to create a no-op finalizer just to please this GC code. In some cases I will be managing memory a bit more manually and don't care to have Emacs doing anything for me.

Thx.

Jess

On Fri, Feb 19, 2016 at 3:33 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> From: Jess Balint <jbalint@gmail.com>
> Date: Thu, 18 Feb 2016 15:52:55 -0600
>
> Dynamic modules are really cool so far, but I think finalizers should
> not be mandatory for user pointers (alloc.c):
>
> #ifdef HAVE_MODULES
>             else if (mblk->markers[i].m.u_any.type == Lisp_Misc_User_Ptr)
>               {
>                 struct Lisp_User_Ptr *uptr = &mblk->markers[i].m.u_user_ptr;
>                 uptr->finalizer (uptr->p); <----- should NULL-check first
>               }
> #endif
>
> c.f. https://github.com/emacs-mirror/emacs/blob/master/src/alloc.c#L6893

Can you tell more about the use case where you needed this change?  A
user-pointer holds a pointer to some unspecified data, and that data
needs to be free'd when the user-pointer object is GC'ed; failure to
do so will cause memory leaks.  When is the above incorrect, or gets
in your way?

Thanks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]