]> granicus.if.org Git - libvpx/commitdiff
aom_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>
Thu, 8 Sep 2016 17:45:15 +0000 (10:45 -0700)
removes the need for an intermediate cast to int, which was missing in
the call added in:
73a3fd4 aom_mem: Refactor code

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

Change-Id: I76c4003416759c6c76b78f74de7c0d2ba5071216

aom_mem/aom_mem.c
aom_mem/include/aom_mem_intrnl.h

index 144085f22f65f5390b5e9d7344d792dfebd7c38f..4514fb54ad57d9909cc6a41b59dee7cc628275e5 100644 (file)
@@ -42,7 +42,7 @@ void *aom_memalign(size_t align, size_t size) {
   const size_t aligned_size = GetAlignedMallocSize(size, align);
   void *const addr = malloc(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);
     SetActualMallocAddress(x, addr);
   }
   return x;
index 2e96fa464b9cacfcaf97f98937d84b348712bc58..3cdfbe08df4cda474ea7638cd621792c46ced993 100644 (file)
@@ -27,6 +27,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  // AOM_MEM_INCLUDE_AOM_MEM_INTRNL_H_