第41章 未整理チャンク( Unsorted Chunk )のマクロ

未整理チャンクは新たなチャンクを、既存のチャンクの分割をして割り当てた際には、最初に未整理チャンクに配置されます。

malloc.c(https://github.com/MacKomatsu/glibc/blob/release/2.27/master/malloc/malloc.c). 

1509 /*
1510    Unsorted chunks
1511
1512     All remainders from chunk splits, as well as all returned chunks,
1513     are first placed in the "unsorted" bin. They are then placed
1514     in regular bins after malloc gives them ONE chance to be used before
1515     binning. So, basically, the unsorted_chunks list acts as a queue,
1516     with chunks being placed on it in free (and malloc_consolidate),
1517     and taken off (to be either used or placed in bins) in malloc.
1518
1519     The NON_MAIN_ARENA flag is never set for unsorted chunks, so it
1520     does not have to be taken into account in size comparisons.
1521  */
1522
1523 /* The otherwise unindexable 1-bin is used to hold unsorted chunks. */
1524 #define unsorted_chunks(M)          (bin_at (M, 1))

このチャンクはビンのインデックス 1 にあるので、デバッグ時には比較的見つけやすいかと思います。

Copyright 2018-2019, by Masaki Komatsu