struct_size_t(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

okay so bestie, welcome to struct_size_t(9) from the Kernel API Manual πŸ’– β€” this is the little helper whose whole gig is: calculate size of structure with trailing flexible array. yes, it’s giving flexible-array math with main character energy πŸŽ€.


🌸 SYNOPSIS 🌸

struct_size_t (type , member , count );

πŸŽ€ ARGUMENTS πŸŽ€

  • type β€” structure type name. like, the actual type bestie, no cap.
  • member β€” name of the array member. the flexible-array member in question πŸ’….
  • count β€” number of elements in the array. how many little elements are living in there 🫢.

πŸ’œ DESCRIPTION πŸ’œ

so it calculates size of memory needed for structure type followed by an array of count number of member elements β€” literally the whole package, structure plus trailing array, sized correctly ✨.

lowkey though: prefer using struct_size when possible instead, because that keeps calculations associated with a specific instance variable of type type β€” and that association is kind of a big deal, iykyk 🧚.


🌈 RETURN 🌈

it returns the number of bytes needed, or SIZE_MAX on overflow 😭. overflow said β€œnot today,” and honestly? valid.


πŸ¦‹ SEE ALSO πŸ¦‹

the Kernel file for all this overflow math is ./include/linux/overflow.h β€” and the whole squad is here: check_add_overflow(9), wrapping_add(9), wrapping_assign_add(9), check_sub_overflow(9), wrapping_sub(9), wrapping_assign_sub(9), check_mul_overflow(9), wrapping_mul(9), check_shl_overflow(9), overflows_type(9), range_overflows(9), range_overflows_t(9), range_end_overflows(9), range_end_overflows_t(9), castable_to_type(9), size_mul(9), size_add(9), size_sub(9), array_size(9), array3_size(9), flex_array_size(9), struct_size(9), struct_offset(9), __DEFINE_FLEX(9), _DEFINE_FLEX(9), DEFINE_RAW_FLEX(9), DEFINE_FLEX(9), STACK_FLEX_ARRAY_SIZE(9), typeof_flex_counter(9), overflows_flex_counter_type(9), __set_flex_counter(9) πŸ’–.


okay bye bestie πŸ’‹ β€” source/version is ./include/linux, date is October 2026, and this struct_size_t(9) page is officially wrapped. go size those flexible arrays with main character energy πŸŒˆπŸ‘‘.

πŸ“¦ where this page comes from