mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Update from Gnulib by running admin/merge-gnulib
This commit is contained in:
parent
f68d962ede
commit
a902156068
14 changed files with 221 additions and 113 deletions
|
|
@ -43,7 +43,7 @@
|
|||
followed by N bytes of other data. The result is suitable as an
|
||||
argument to malloc. For example:
|
||||
|
||||
struct s { int n; char d[FLEXIBLE_ARRAY_MEMBER]; };
|
||||
struct s { int a; char d[FLEXIBLE_ARRAY_MEMBER]; };
|
||||
struct s *p = malloc (FLEXSIZEOF (struct s, d, n * sizeof (char)));
|
||||
|
||||
FLEXSIZEOF (TYPE, MEMBER, N) is not simply (sizeof (TYPE) + N),
|
||||
|
|
@ -63,3 +63,14 @@
|
|||
#define FLEXSIZEOF(type, member, n) \
|
||||
((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
|
||||
& ~ (FLEXALIGNOF (type) - 1))
|
||||
|
||||
/* Yield a properly aligned upper bound on the size of a struct of
|
||||
type TYPE with a flexible array member named MEMBER that has N
|
||||
elements. The result is suitable as an argument to malloc.
|
||||
For example:
|
||||
|
||||
struct s { int a; double d[FLEXIBLE_ARRAY_MEMBER]; };
|
||||
struct s *p = malloc (FLEXNSIZEOF (struct s, d, n));
|
||||
*/
|
||||
#define FLEXNSIZEOF(type, member, n) \
|
||||
FLEXSIZEOF (type, member, (n) * sizeof (((type *) 0)->member[0]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue