Heap analysis/glibc 2.26
(glibc 2.26) tcache_put
lok2h4rd
2022. 5. 1. 20:37
/* Caller must ensure that we know tc_idx is valid and there's room
for more chunks. */
static void
tcache_put (mchunkptr chunk, size_t tc_idx)
{
tcache_entry *e = (tcache_entry *) chunk2mem (chunk);
assert (tc_idx < TCACHE_MAX_BINS);
e->next = tcache->entries[tc_idx];
tcache->entries[tc_idx] = e;
++(tcache->counts[tc_idx]);
}
tcache에 freed 청크를 넣는 작업을 하는 함수이다
- 포인터 e에 chunk주소 저장
- tc_idx가 TCACHE_MAX_BINS보다 작은지 검사
- 엔트리에 저장된 값을 포인터 e->next에 저장
- 엔트리에 e 저장
- count를 1증가