Browse Source

Merge pull request #868 from nakst/patch-1

Make size of allocation multiple of the alignment
gingerBill 4 years ago
parent
commit
85fd8aaf37
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/gb/gb.h

+ 1 - 1
src/gb/gb.h

@@ -5026,7 +5026,7 @@ GB_ALLOCATOR_PROC(gb_heap_allocator_proc) {
 #elif defined(GB_SYSTEM_LINUX)
 	// TODO(bill): *nix version that's decent
 	case gbAllocation_Alloc: {
-		ptr = aligned_alloc(alignment, size);
+		ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1));
 		// ptr = malloc(size+alignment);
 
 		if (flags & gbAllocatorFlag_ClearToZero) {