flex_array_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… flex_array_size(9) β€” the Kernel API Manual, but make it make sense 🫢

okay so bestie, this page lives in the Kernel API Manual and it's literally all about not getting owned by arithmetic while you're sizing up a flexible array member. tiny function, huge slay. let's get into it ✨


πŸ’– NAME πŸ’–

flex_array_size β€” Calculate size of a flexible array member within an enclosing structure.

yes that's the whole vibe. it tells you how many bytes that trailing flexible array actually eats. iconic behaviour honestly πŸŽ€


✨ SYNOPSIS ✨

flex_array_size (p , member , count );

look at her. three args. no notes. πŸ’…


🌸 ARGUMENTS 🌸

  • p β€” Pointer to the structure. like, the actual struct, bestie, not a copy, the pointer. πŸ‘‘
  • member β€” Name of the flexible array member. the one chilling at the end of the struct doing its thing.
  • count β€” Number of elements in the array. how many of them you want, fr fr.

πŸ¦‹ DESCRIPTION πŸ¦‹

Calculates size of a flexible array of count number of member elements, at the end of structure p.

that's it. that's the whole bit. you hand it the struct pointer, the member name, and a count, and it hands you back the byte math. no cap, it's giving "trusted friend who does your taxes" energy 🧚


πŸ”₯ RETURN πŸ”₯

number of bytes needed β€” or SIZE_MAX on overflow. 😭 so like, if the math blows up it does not just quietly wrap around and hand you a cursed number; it gives you SIZE_MAX so you can go "oh no bestie" and bail. check for it. please. πŸ™ˆ


🌈 SEE ALSO 🌈

Kernel file ./include/linux/overflow.h β€” the mothership, honestly. πŸ’œ

and then the whole friend group, all in section (9):

the entire overflow.h cinematic universe, and every single one of them is on their grind ⭐


lowkey important: this is the whole page. that's everything it says. so don't come for me about missing lore β€” there isn't any. go read overflow.h if you want the director's commentary πŸ“

okay and finally, the little sign-off the page carries at the bottom: it's sourced from ./include/linux, dated October 2026. so when you cite it, that's the receipt. periodt. πŸ«ΆπŸ’–

πŸ“¦ where this page comes from