diff options
author | Evan Huus <eapache@gmail.com> | 2014-03-03 23:44:12 -0500 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-03-04 17:09:40 +0000 |
commit | 35098d20a2fb7a635156d69e916e26352d8d935a (patch) | |
tree | c75b8a55d118f2fb127ff8d7fea98cb1d9727a18 /epan/wmem | |
parent | 75a67e699137e0de2d60c0339f91affaba6a0780 (diff) |
Fix memory-alignment in the block allocator.
The previous macro gave the correct alignment, but there was one case where it
would add a whole block of unnecessary ALIGN_SIZE bytes. The new one is also
slightly faster to compute.
Benchmark win of about 3%.
Change-Id: I5d8bad0f78dc0e383e14c2c7a951328a06400020
Reviewed-on: https://code.wireshark.org/review/492
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/wmem')
-rw-r--r-- | epan/wmem/wmem_allocator_block.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/epan/wmem/wmem_allocator_block.c b/epan/wmem/wmem_allocator_block.c index 7ff5da4a15..e5be6b8a07 100644 --- a/epan/wmem/wmem_allocator_block.c +++ b/epan/wmem/wmem_allocator_block.c @@ -144,8 +144,8 @@ * we don't need to do better than malloc. */ #define WMEM_ALIGN_AMOUNT (2 * sizeof (gsize)) -#define WMEM_ALIGN_SIZE(SIZE) ((SIZE) + WMEM_ALIGN_AMOUNT - \ - ((SIZE) & (WMEM_ALIGN_AMOUNT - 1))) +#define WMEM_ALIGN_SIZE(SIZE) ((~(WMEM_ALIGN_AMOUNT-1)) & \ + ((SIZE) + (WMEM_ALIGN_AMOUNT-1))) /* When required, allocate more memory from the OS in chunks of this size. * 8MB is a pretty arbitrary value - it's big enough that it should last a while |