[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: valid_pointer_p
From: |
Kim F. Storm |
Subject: |
Re: valid_pointer_p |
Date: |
Sat, 12 Aug 2006 22:19:50 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
>> From: Andreas Schwab <address@hidden>
>> Cc: address@hidden (Kim F. Storm), address@hidden
>> Date: Sat, 12 Aug 2006 14:36:22 +0200
>>
>> Eli Zaretskii <address@hidden> 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?
No. My simple approach was simply to assume that if you can access the
size field of a vector, you can access the rest as well. I don't mind
making a more correct implementation, although I didn't see the need --
after all, this is for a corner case of debugging emacs.
--
Kim F. Storm <address@hidden> http://www.cua.dk
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/05
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/05
- Re: valid_pointer_p, Kim F. Storm, 2006/08/05
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/05
- Re: valid_pointer_p, Kim F. Storm, 2006/08/11
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/12
- Re: valid_pointer_p, Andreas Schwab, 2006/08/12
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/12
- Re: valid_pointer_p,
Kim F. Storm <=
- Re: valid_pointer_p, Eli Zaretskii, 2006/08/12