[Top][All Lists]

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

Re: good examples of Emacs modules?

From: Eli Zaretskii
Subject: Re: good examples of Emacs modules?
Date: Fri, 01 Apr 2016 17:07:50 +0300

> From: Óscar Fuentes <address@hidden>
> Date: Fri, 01 Apr 2016 15:25:42 +0200
> Eli Zaretskii <address@hidden> writes:
> > I think you want to wrap some kind of "handle" that is meaningful to
> > libgit2 into a user-ptr object (see the existing docs about modules
> > for details about these).  A user-ptr object has a finalizer, a
> > function that is called by GC when the object goes out of scope.
> This means that GCing the object is unpredictable, right?

It's as predictable and as unpredictable as what you have with any
other Lisp object.  As long as the object is referenced, it will not
be GC'ed.

> Also, if the API uses a struct as the session object, you need to
> store it somewhere and expose a pointer to it to the Elisp code;
> that is, you can't put arbitrary data on the Elisp memory space.

The user-ptr object is precisely the way to produce a Lisp object that
holds such a pointer, so I'm not sure why you are describing this as
some kind of problem: it's a solution, not a problem.  You allocate
memory for the struct, store the info there, then wrap the resulting
pointer in user-ptr, and that's it.  (The finalizer should free the
memory and perform whatever other cleanup is needed.)  If this is
somehow problematic, please tell why.

reply via email to

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