Use uintptr_t instead of size_t, since size_t is not guaranteed to be pointer-sized.

This commit is contained in:
Quentin Smith
2012-03-23 02:13:55 -04:00
committed by Keith Winstein
parent 0d6875b8be
commit d867a716b7
+2 -2
View File
@@ -59,13 +59,13 @@ static void * aligned_alloc( int len )
if( ! (ptr = malloc(len)) ) { if( ! (ptr = malloc(len)) ) {
throw std::bad_alloc(); throw std::bad_alloc();
} }
if( (size_t)ptr & 0xF ) { if( (uintptr_t)ptr & 0xF ) {
// The pointer wasn't 16-byte aligned, so try again with valloc // The pointer wasn't 16-byte aligned, so try again with valloc
free(ptr); free(ptr);
if( ! (ptr = valloc(len)) ) { if( ! (ptr = valloc(len)) ) {
throw std::bad_alloc(); throw std::bad_alloc();
} }
if( (size_t)ptr & 0xF ) { if( (uintptr_t)ptr & 0xF ) {
free(ptr); free(ptr);
throw std::bad_alloc(); throw std::bad_alloc();
} }