diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-01 09:21:15 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-01 09:23:37 +0000 |
commit | a0fb1391315033de54368715a8855aedea258e67 (patch) | |
tree | b94acce313a3e33c0dd8792248396e61894c2d71 /src/cairo-mempool.c | |
parent | 153b11612f34294241429b53722839984f367f2e (diff) | |
download | cairo-a0fb1391315033de54368715a8855aedea258e67.tar.gz |
mempool: Reduce the assertion into an alignment adjustment for the base
Instead of asserting that the caller passed in a chunk-aligned base
pointer, just perform the fixup whilst initialising the mempool. This
means that the caller (xcb!) cannot assume that the mempool->base is
then the same base pointer as passed in and so needs to store it
separately for use in computing SHM offsets.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-mempool.c')
-rw-r--r-- | src/cairo-mempool.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c index 296b73932..96e4a62b2 100644 --- a/src/cairo-mempool.c +++ b/src/cairo-mempool.c @@ -283,9 +283,18 @@ _cairo_mempool_init (cairo_mempool_t *pool, void *base, size_t bytes, int min_bits, int num_sizes) { + unsigned long tmp; int num_blocks; int i; + /* Align the start to an integral chunk */ + tmp = ((unsigned long) base) & ((1 << min_bits) - 1); + if (tmp) { + tmp = (1 << min_bits) - tmp; + base = (char *)base + tmp; + bytes -= tmp; + } + assert ((((unsigned long) base) & ((1 << min_bits) - 1)) == 0); assert (num_sizes < ARRAY_LENGTH (pool->free)); |