[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lisp object that refers to a C struct
From: |
Eli Zaretskii |
Subject: |
Re: Lisp object that refers to a C struct |
Date: |
Thu, 18 Oct 2012 19:16:09 +0200 |
> From: Stefan Monnier <address@hidden>
> Cc: Juanma Barranquero <address@hidden>, address@hidden, address@hidden
> Date: Thu, 18 Oct 2012 08:33:59 -0400
>
> >> In that case, wouldn't it be better to have the integer be an index
> >> into a table, like Stefan suggested?
> > It's easy to do that (of course, at a price of some slightly more
> > complicated memory management),
>
> I don't understand why the memory management would care about which
> integer you use to represent file-watcher descriptors.
It doesn't. I meant the need to manage the table itself, grow it when
needed, etc.
> > but I think Stefan still prefers the "new object" solution.
>
> I generally like stronger types, so you're probably right, but an "index
> into a table" doesn't necessarily sound so terribly bad, if you have
> such a table anyway
I don't have a table. What I have is an association list. I used the
same method as RĂ¼diger in his inotify patch.
> (BTW, is this table usable by Lisp, e.g. can they get the list of
> current file-watchers?).
Yes, it's an alist. But it currently isn't exposed to Lisp, neither
as a variable nor via an API. It could be, of course. But since
RĂ¼diger didn't, and since we didn't discuss in detail how this feature
will be used from Lisp, I didn't want to introduce APIs whose
necessity is not clear.
> >> It's faster to check that it is in range than compare it with an
> >> arbitrarily long list of known pointers.
> > That's not what the code does. It calls Fassoc_quit to find the
I meant Fassoc, of course.
> > descriptor in the list of known live watches (which will still be
> > needed under the table suggestion),
>
> Isn't Fassoc_quit going to "compare it with an arbitrarily long list"?
> To me this "list of known live watches" sounds exactly like the "table"
> I mention above.
Yes, but since it's an alist, I get its memory management for free.
> > and then validates the pointer itself, just in case (which is also
> > independent of the table suggestion).
>
> What means "validate"?
Call w32_valid_pointer_p, and in addition verify that the struct
pointed to by it has the correct magic signature.
- Re: Lisp object that refers to a C struct, (continued)
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/18
- Re: Lisp object that refers to a C struct, Paul Eggert, 2012/10/18
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/18
- Re: Lisp object that refers to a C struct, Paul Eggert, 2012/10/18
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/18
- Re: Lisp object that refers to a C struct, Juanma Barranquero, 2012/10/18
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/18
- Re: Lisp object that refers to a C struct, Stefan Monnier, 2012/10/18
- Re: Lisp object that refers to a C struct,
Eli Zaretskii <=
- Re: Lisp object that refers to a C struct, Stefan Monnier, 2012/10/18
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/19
- Re: Lisp object that refers to a C struct, Stefan Monnier, 2012/10/19
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/19
- Re: Lisp object that refers to a C struct, Stefan Monnier, 2012/10/19
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/19
- Re: Lisp object that refers to a C struct, Stefan Monnier, 2012/10/19
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/20
- Re: Lisp object that refers to a C struct, Eli Zaretskii, 2012/10/17
- Re: Lisp object that refers to a C struct, Davis Herring, 2012/10/17