浏览代码

Make sure we don't allocate too little space for static free-areas
because of our fiddling with alignment (because doing so is VERY BAD).

Miles Bader 22 年之前
父节点
当前提交
a436319a3a
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      libc/stdlib/malloc/heap.h

+ 3 - 1
libc/stdlib/malloc/heap.h

@@ -78,7 +78,9 @@ struct heap_free_area
 #define HEAP_DECLARE_STATIC_FREE_AREA(name, size)			      \
   static struct								      \
   {									      \
-    HEAP_GRANULARITY_TYPE space[((size) - sizeof (struct heap_free_area))     \
+    HEAP_GRANULARITY_TYPE space[((size)					      \
+				 - sizeof (struct heap_free_area)	      \
+				 + (HEAP_GRANULARITY - 1))		      \
 				/ HEAP_GRANULARITY];			      \
     struct heap_free_area _fa;						      \
   } name = { { (HEAP_GRANULARITY_TYPE)0 }, { (size), 0, 0 } }