From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: valid_pointer_p Date: Sat, 12 Aug 2006 17:39:30 +0300 Message-ID: References: Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1155393594 19011 80.91.229.2 (12 Aug 2006 14:39:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 12 Aug 2006 14:39:54 +0000 (UTC) Cc: emacs-devel@gnu.org, storm@cua.dk Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 12 16:39:53 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GBueQ-0002hu-KF for ged-emacs-devel@m.gmane.org; Sat, 12 Aug 2006 16:39:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GBueQ-0000Er-0D for ged-emacs-devel@m.gmane.org; Sat, 12 Aug 2006 10:39:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GBueC-0000Bn-Mh for emacs-devel@gnu.org; Sat, 12 Aug 2006 10:39:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GBueB-0000A4-QB for emacs-devel@gnu.org; Sat, 12 Aug 2006 10:39:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GBueB-00009q-Me for emacs-devel@gnu.org; Sat, 12 Aug 2006 10:39:31 -0400 Original-Received: from [192.114.186.73] (helo=heller.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GBujZ-0003rT-1S for emacs-devel@gnu.org; Sat, 12 Aug 2006 10:45:05 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-80-230-154-186.inter.net.il [80.230.154.186]) by heller.inter.net.il (MOS 3.7.3a-GA) with ESMTP id AFB87096 (AUTH halo1); Sat, 12 Aug 2006 17:39:25 +0300 (IDT) Original-To: Andreas Schwab In-reply-to: (message from Andreas Schwab on Sat, 12 Aug 2006 14:36:22 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58322 Archived-At: > From: Andreas Schwab > Cc: storm@cua.dk (Kim F. Storm), emacs-devel@gnu.org > Date: Sat, 12 Aug 2006 14:36:22 +0200 > > Eli Zaretskii 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?