all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: "Elias Mårtenson" <lokedhs@gmail.com>,
	"Paul Eggert" <eggert@cs.ucla.edu>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Module support: No environment in pointer release function
Date: Tue, 07 Feb 2017 12:54:32 +0000	[thread overview]
Message-ID: <CAArVCkTKU5zUSXdU1AEtxNHdAf0nOqV0+UyESpegzqxtHSmzTA@mail.gmail.com> (raw)
In-Reply-To: <CADtN0W+kxpR+WuEpDoieRGYzQ1dfrgP-tK4VkW5c3yPiDnzHjA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]

Elias Mårtenson <lokedhs@gmail.com> schrieb am Di., 7. Feb. 2017 um
04:16 Uhr:

> On 6 February 2017 at 13:33, Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Elias Mårtenson wrote:
>
> In
> addition to the pointer itself, the ‘emacs_env’ pointer is needed. An
> arbitrary ‘void *data’ pointer would be useful too.
>
>
> Can you package up these pointers into a single data structure, and pass a
> pointer to that structure? That's what's usually done in situations like
> this, and is why a single 'void *' should suffice.
>
>
> I could do this, but as far as I understood, the emacs_env pointer is not
> guaranteed to be immutable. If it isn't immutable, then I might just as
> well save it to a global variable and not have to pass it through every
> function that needs it.
>
> What are the guarantees with regards to the emacs_env value?
>

The big restriction is that its lifetime is limited to the lifetime
(storage duration) of the argument that is used to obtain the pointer. I.e.
in a function

emacs_value module_fun(emacs_env* env, ...) { ... }

the environment represented by env is only valud in the body of module_fun;
reusing env or *env once the body is finished is undefined behavior.
(I'm aware that this is not documented at all, and I've been meaning to
write some documentation for a while.)

[-- Attachment #2: Type: text/html, Size: 2566 bytes --]

  parent reply	other threads:[~2017-02-07 12:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03  2:55 Module support: No environment in pointer release function Elias Mårtenson
2017-02-06  5:33 ` Paul Eggert
2017-02-07  3:16   ` Elias Mårtenson
2017-02-07  6:41     ` Paul Eggert
2017-02-07 12:54     ` Philipp Stephani [this message]
2017-02-07 12:51   ` Philipp Stephani
2017-02-07 12:50 ` Philipp Stephani
2017-02-08 17:03 ` Andreas Politz
2017-02-10  5:21   ` Elias Mårtenson
2017-02-10  5:22     ` Elias Mårtenson
2017-02-10  9:27     ` Andreas Politz
2017-02-26 16:23     ` Philipp Stephani
2017-02-27  4:31       ` Elias Mårtenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAArVCkTKU5zUSXdU1AEtxNHdAf0nOqV0+UyESpegzqxtHSmzTA@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=lokedhs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.