From: Paul Eggert Date: Thu, 10 Oct 2002 07:25:21 +0000 (+0000) Subject: (bitsetv_alloc): Return a size that is aligned properly for vectors of X-Git-Tag: BISON-1_75~48 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/f5e211a120f1e508a98ce8e6b823c3750b0cfeed (bitsetv_alloc): Return a size that is aligned properly for vectors of objects. Do not assume that adding a header size to a multiple of a word size yields a value that is properly aligned for the whole union. (bitsetv_alloc): Add a cast to (void *) to avoid a GCC warning. --- diff --git a/lib/bitsetv.c b/lib/bitsetv.c index 2c26549a..ecec0610 100644 --- a/lib/bitsetv.c +++ b/lib/bitsetv.c @@ -32,7 +32,7 @@ bitset * bitsetv_alloc (n_vecs, n_bits, type) bitset_bindex n_vecs; bitset_bindex n_bits; - enum bitset_type type; + enum_bitset_type type; { size_t vector_bytes; size_t bytes; @@ -47,12 +47,13 @@ bitsetv_alloc (n_vecs, n_bits, type) xalloc_die (); /* Allocate vector table at head of bitset array. */ - vector_bytes = (n_vecs + 1) * sizeof (bitset); + vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1; + vector_bytes -= vector_bytes % bytes; bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs); for (i = 0; i < n_vecs; i++) { - bsetv[i] = (bitset) ((char *) bsetv + vector_bytes + i * bytes); + bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes); bitset_init (bsetv[i], n_bits, type); } @@ -94,7 +95,7 @@ bitsetv_free (bsetv) /* Zero a vector of bitsets. */ void bitsetv_zero (bsetv) - struct bitset_struct **bsetv; + bitsetv bsetv; { bitset_bindex i;