assoc_array_gc(9)
π assoc_array_gc β Garbage collect an associative array π
okay bestie, welcome to the Kernel API Manual entry for assoc_array_gc β yes it's a kernel function, yes it's in section 9, and yes we're gonna get through it together π«Ά
β¨ NAME β¨
assoc_array_gc β Collect garbage from an associative array, bestie. That's literally the whole job π
πΈ SYNOPSIS πΈ
int assoc_array_gc (struct assoc_array *array , const struct
assoc_array_ops *ops , bool (*iterator)(void *object, void
*iterator_data) , void *iterator_data );
look at that signature. four whole parameters. she's thorough π
π ARGUMENTS π
arrayβ the array you wanna clean, bestie. the glow-up target πopsβ the operations to use. like, the instruction set for the whole operation β¨iteratorβ a callback function that gets to pass judgement on each object. she's the judge, jury, and vibe checker πiterator_dataβ private data for the callback function. just for her, no one else π
π¦ DESCRIPTION π¦
So the whole point: this function collects garbage from an associative array and packs down the internal tree to save memory. it's giving spring cleaning π§Ήπ
The iterator function is asked to pass judgement upon each object in the array. and this is the important part, so listen up:
- if it returns
false, the object is discarded (gone, bye π) - if it returns
true, the object is kept
and if it returns true, it must increment the object's usage count (or whatever it needs to do to retain it) before returning. like, no cap, do the bookkeeping first π₯
This function returns 0 if successful or -ENOMEM if out of memory. In the latter case, the array is not changed π«Ά
β the caller should lock against other modifications and must continue to hold the lock until assoc_array_apply_edit has been called. do not let go early, bestie π
Accesses to the tree may take place concurrently with this function, provided they hold the RCU read lock. so yeah, other readers can vibe alongside, as long as they've got that lock π
π SEE ALSO π
Kernel file ./lib/assoc_array.c β and the whole assoc_array friend group, honestly:
assoc_array_iterate(9)assoc_array_find(9)assoc_array_destroy(9)assoc_array_insert(9)assoc_array_insert_set_object(9)assoc_array_delete(9)assoc_array_clear(9)assoc_array_apply_edit(9)assoc_array_cancel_edit(9)
go read them, they all ate π β¨
and that's the page, bestie π this one lives in ./lib, October 2026 edition β so if you stan the kernel source era, this is your page. mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms