Browse code

Fix alignment calculation.

Török Edvin authored on 2010/06/29 19:25:11
Showing 1 changed files
... ...
@@ -456,6 +456,7 @@ static inline unsigned int alignof(unsigned int size)
456 456
 	case 0:
457 457
 	    return 8;
458 458
 	case 2:
459
+	case 6:
459 460
 	    return 2;
460 461
 	case 4:
461 462
 	    return 4;
... ...
@@ -647,7 +648,7 @@ void *mpool_malloc(struct MP *mp, size_t size) {
647 647
     struct FRAG *fold = f;
648 648
     mp->avail[sbits] = f->u.next.ptr;
649 649
     /* we always have enough space for this, align_increase ensured that */
650
-    f = (struct FRAG*)alignto((unsigned long)f, align);
650
+    f = (struct FRAG*)(alignto((unsigned long)f + FRAG_OVERHEAD, align)-FRAG_OVERHEAD);
651 651
     f->u.a.sbits = sbits;
652 652
     f->u.a.padding = (char*)f - (char*)fold;
653 653
 #ifdef CL_DEBUG