Arena allocators
Në shqip: Alokuesit „arena“
ShpjegimiSQ
Një arena merr një bllok të madh memorieje dhe ua jep copat me radhë; në fund e liron të gjithë bllokun njëherësh, pa free() për çdo objekt. E thjeshtë, e shpejtë, dhe pa memory leak.
EnglishEN
An arena takes one big block of memory and hands out pieces in order; at the end it frees the whole block at once, without free() for each object. Simple, fast, and leak-free.
Si ta mendosh
Si një tavolinë pikniku: vendos gjithçka mbi të, dhe në fund palos gjithë mbulesën njëherësh.
Lexoje në anglisht
Like a picnic blanket: put everything on it, and at the end fold up the whole blanket at once.
Shembull kodic
typedef struct { char *mem; size_t perdorur, madhesia; } Arena;
void *arena_merr(Arena *a, size_t n) {
void *p = a->mem + a->perdorur; a->perdorur += n; return p;
}