/* -----------------------------------------------------------------------------
- $Id: Arena.c,v 1.1 2001/10/18 14:41:01 simonmar Exp $
+ $Id: Arena.c,v 1.4 2002/07/28 02:31:11 sof Exp $
(c) The University of Glasgow 2001
Arena allocation. Arenas provide fast memory allocation at the
which most allocations are small.
-------------------------------------------------------------------------- */
+#include <stdlib.h>
#include "Rts.h"
#include "RtsUtils.h"
#include "BlockAlloc.h"
nat req_blocks;
bdescr *bd;
- // round up to word size...
- size_w = (size + sizeof(W_) - 1) / sizeof(W_);
+// The minimum alignment of an allocated block.
+#define MIN_ALIGN 8
+
+ // size of allocated block in words, rounded up to the nearest
+ // alignment chunk.
+ size_w = ((size + MIN_ALIGN - 1) / MIN_ALIGN) * (MIN_ALIGN/sizeof(W_));
if ( arena->free + size_w < arena->lim ) {
// enough room in the current block...