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>
* 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