vpx_mem,align_addr: use ~ to create mask
authorJames Zern <jzern@google.com>
Sat, 27 Aug 2016 17:34:40 +0000 (10:34 -0700)
committerJames Zern <jzern@google.com>
Sat, 27 Aug 2016 18:39:18 +0000 (11:39 -0700)
removes the need for an intermediate cast to int, which was missing in
the call added in:
69c5ba1 vpx_mem: Refactor code

quiets a visual studio warning:
C4146: unary minus operator applied to unsigned type, result still
unsigned

Change-Id: I76c4003416759c6c76b78f74de7c0d2ba5071216

vpx_mem/include/vpx_mem_intrnl.h
vpx_mem/vpx_mem.c

index b62d238..2c259d3 100644 (file)
@@ -26,6 +26,6 @@
 
 /*returns an addr aligned to the byte boundary specified by align*/
 #define align_addr(addr, align) \
-  (void *)(((size_t)(addr) + ((align)-1)) & (size_t) - (align))
+  (void *)(((size_t)(addr) + ((align)-1)) & ~(size_t)((align)-1))
 
 #endif  // VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_
index 4f4e0dd..138a540 100644 (file)
@@ -59,7 +59,7 @@ void *vpx_memalign(size_t align, size_t size) {
 
   addr = malloc((size_t)aligned_size);
   if (addr) {
-    x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
+    x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, align);
     set_actual_malloc_address(x, addr);
   }
   return x;