mempool_init(9)
π mempool_init(9) π
okay so we're in the Kernel API Manual bestie, and today's main character is mempool_init(9) β the pool-initializing icon herself β¨
πΈ NAME πΈ
mempool_init β initialize a memory pool π«Ά
β¨ SYNOPSIS β¨
int mempool_init (struct mempool *pool , int min_nr , mempool_alloc_t
*alloc_fn , mempool_free_t *free_fn , void *pool_data );
like, that's the whole signature, no cap π
π ARGUMENTS π
poolβ pointer to the memory pool that should be initialized. this is the glow-up target bestie πmin_nrβ the minimum number of elements guaranteed to be allocated for this pool. the bare minimum, and honestly? we respect a guaranteed floor β¨alloc_fnβ user-defined element-allocation function. your own custom allocator, you do it yourself, main character energy πfree_fnβ user-defined element-freeing function. the matching cleanup bestie, they're a set fr fr π«Άpool_dataβ optional private data available to the user-defined functions. little secret stash for your callbacks, iykyk π
π¦ DESCRIPTION π¦
So like... it's mempool_create, but the plot twist is it initializes the pool in place (i.e. embedded in another structure). same vibes, different placement β the pool lives inside your other struct instead of getting its own separate home. lowkey iconic, highkey efficient π
β¨
β RETURN β
0 on success, negative error code otherwise. zero means slay, negative means π
π₯ SEE ALSO π₯
Kernel file ./mm/mempool.c β and the whole friend group: mempool_exit(9), mempool_destroy(9), mempool_create_node(9), mempool_resize(9), mempool_alloc_bulk(9), mempool_alloc(9), mempool_alloc_preallocated(9), mempool_free_bulk(9), mempool_free(9) π§ββοΈπ
and that's the page bestie!! brought to you by the fine people over at ./mm π, dated October 2026 π β go forth and initialize something, periodt π
π¦ 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