free
Besplatni Pregled Narudžbine
(Nisu objašnjene sve provere u ovom pregledu i neki slučajevi su izostavljeni radi sažetosti)
Ako je adresa null, ne čini ništa
Ako je blok bio mapiran, odmapiraj ga i završi
Pozovi
_int_free
:Ako je moguće, dodaj blok u tcache
Ako je moguće, dodaj blok u brzi bin
Pozovi
_int_free_merge_chunk
da konsoliduje blok ako je potrebno i dodaj ga u nesortiranu listu
__libc_free
Free
poziva __libc_free
.
Ako je prosleđena adresa Null (0), ne čini ništa.
Proveri oznaku pokazivača
Ako je blok
mapiran
,odmapiraj
ga i to je sveAko nije, dodaj boju i pozovi
_int_free
nad njim
_int_free tcache
Prvo će pokušati da alocira ovaj blok u povezanoj tcache. Međutim, neke provere se vrše unapred. Proći će kroz sve blokove tcache-a na istom indeksu kao oslobođeni blok i:
Ako ima više unosa od
mp_.tcache_count
:free(): previše blokova otkriveno u tcache-u
Ako unos nije poravnan:
free(): otkriven neusaglašen blok u tcache-u 2
ako je oslobođeni blok već oslobođen i prisutan je kao blok u tcache-u:
free(): otkriven dvostruki free u tcache-u 2
Ako sve prođe kako treba, blok se dodaje u tcache i funkcija se završava.
_int_free_merge_chunk
Ova funkcija će pokušati da spoji blok P veličine SIZE bajtova sa svojim susedima. Rezultujući blok će biti stavljen na listu nesortiranih blokova.
Vrše se neke provere:
Ako je blok vrhunski blok:
double free or corruption (top)
Ako je sledeći blok van granica arene:
double free or corruption (out)
Ako blok nije označen kao korišćen (u
prev_inuse
od sledećeg bloka):double free or corruption (!prev)
Ako sledeći blok ima previše malu ili preveliku veličinu:
free(): invalid next size (normal)
ako prethodni blok nije u upotrebi, pokušaće da konsoliduje. Ali, ako se prev_size razlikuje od veličine naznačene u prethodnom bloku:
corrupted size vs. prev_size while consolidating
Last updated