467 do { 468 p = malloc(nbytes); 469 470 if (p == NULL) { 471 p = Out_Of_Space(nbytes); 472 } 473 474 #ifdef HEAP_CHECK 475 Allocated(block_size(p)); 476 #endif 477 /* get 8-byte alignment */ 478 alignment = ((unsigned long)p) & 7; 479 480 if (alignment == 0) { 481 if (align4 && *(int *)(p-4) == MAGIC_FILLER) 482 // don't free. grab a new one. 483 continue; // magic is there by chance! 484 // (this case is remotely possible on Win95 only) 485 return p; // already 8-aligned, should happen most of the time 486 } 487 if (alignment != 4) 488 RTFatal("malloc block NOT 4-byte aligned!\n"); 489 490 if (align4) { 491 *(int *)p = MAGIC_FILLER; 492 return p+4; 493 } 494 495 /* first occurrence of a 4-aligned block */ 496 free(p); 497 align4 = 4; // start handling 4-aligned blocks 498 nbytes += align4; 499 } while (TRUE);