[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Quesition about Lisp_Vector
From: |
Andreas Schwab |
Subject: |
Re: Quesition about Lisp_Vector |
Date: |
Fri, 11 Nov 2011 09:59:53 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Qiang Guo <address@hidden> writes:
> Hi, I'm new to devel aspect of Emacs. And I'm having a problem reading
> Emacs source code: in the definition of Lisp_Vector
> struct Lisp_Vector
> {
> EMACS_UINT size;
> struct Lisp_Vector *next;
> Lisp_Object contents[1];
> };
>
> why contents's size is fixed ?
Standard C89 doesn't have flexible array members, so this is using the
well known struct hack.
> And later when actually allocating space
>
> nbytes = sizeof *p + (len - 1) * sizeof p->contents[0];
>
> I don't understand how this nbytes is calculated. why only (len-1)
Because one element is already included in struct Lisp_Vector.
Andreas.
--
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."