mempool_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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