From: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org, storm@cua.dk
Subject: Re: valid_pointer_p
Date: Sat, 12 Aug 2006 17:39:30 +0300 [thread overview]
Message-ID: <upsf6c925.fsf@gnu.org> (raw)
In-Reply-To: <je3bc2i115.fsf@sykes.suse.de> (message from Andreas Schwab on Sat, 12 Aug 2006 14:36:22 +0200)
> From: Andreas Schwab <schwab@suse.de>
> Cc: storm@cua.dk (Kim F. Storm), emacs-devel@gnu.org
> Date: Sat, 12 Aug 2006 14:36:22 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > ??? Don't we have macros, like INTEGERP, SUBRP, etc. to do that
> > without dereferencing? The length of the primitive Lisp types is
> > known, right?
>
> Try to find out the size of a vector object.
>
> /* Vector of Lisp objects, or something resembling it.
> XVECTOR (object) points to a struct Lisp_Vector, which contains
> the size and contents. The size field also contains the type
> information, if it's not a real vector object. */
> Lisp_Vectorlike,
I think something like this should work for such cases:
struct Lisp_Vector *p = XVECTOR (obj);
if (valid_pointer_p (p, offsetof (struct Lisp_Vector, size)
+ sizeof (EMACS_INT))
&& valid_pointer_p (p, p->size))
return 1; /* valid */
(Modulo the complications of storing other information in the leading
bits of the `size' field of struct Lisp_Vector.) This is what I meant
when I wrote:
Even if you are right, dereferencing a pointer accesses a region in
memory whose length is known in advance, so at most we will need to
call valid_pointer_p twice.
Am I missing something?
next prev parent reply other threads:[~2006-08-12 14:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-29 10:27 valid_pointer_p Eli Zaretskii
2006-07-29 10:45 ` valid_pointer_p Andreas Schwab
2006-07-29 12:16 ` valid_pointer_p Eli Zaretskii
2006-07-30 0:05 ` valid_pointer_p Kim F. Storm
2006-07-30 3:16 ` valid_pointer_p Eli Zaretskii
2006-07-30 22:13 ` valid_pointer_p Kim F. Storm
2006-07-31 3:21 ` valid_pointer_p Eli Zaretskii
2006-07-31 8:30 ` valid_pointer_p Andreas Schwab
2006-07-31 17:10 ` valid_pointer_p Eli Zaretskii
2006-07-31 17:56 ` valid_pointer_p Andreas Schwab
2006-07-31 9:01 ` valid_pointer_p Kim F. Storm
2006-08-05 13:04 ` valid_pointer_p Eli Zaretskii
2006-08-05 13:09 ` valid_pointer_p Eli Zaretskii
2006-08-05 22:11 ` valid_pointer_p Kim F. Storm
2006-08-06 3:29 ` valid_pointer_p Eli Zaretskii
2006-08-11 22:58 ` valid_pointer_p Kim F. Storm
2006-08-12 11:06 ` valid_pointer_p Eli Zaretskii
2006-08-12 12:36 ` valid_pointer_p Andreas Schwab
2006-08-12 14:39 ` Eli Zaretskii [this message]
2006-08-12 20:19 ` valid_pointer_p Kim F. Storm
2006-08-12 21:56 ` valid_pointer_p Eli Zaretskii
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=upsf6c925.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=storm@cua.dk \
/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.