size_mul(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ size_mul(9) ✨

okay so bestie, this one is from the Kernel API Manual and it's genuinely such a little icon πŸ’… β€” it's all about multiplying two sizes together without letting things get out of hand.


🌸 NAME 🌸

size_mul β€” calculates a size_t multiplication, saturating at SIZE_MAX πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

size_t size_mul (size_t factor1 , size_t factor2 );

πŸ’– ARGUMENTS πŸ’–

  • factor1 β€” the first factor, bestie 🌸
  • factor2 β€” the second factor, obviously πŸ’…

⭐ RETURN ⭐

So it calculates factor1 * factor2, with both of them promoted to size_t, and like… if any overflow happens, the return value becomes SIZE_MAX instead. No cap, it just caps out. πŸ‘‘

Also lowkey important: the lvalue must be size_t so you don't get any implicit type conversion sneaking in. Don't do it, bestie β€” type conversion jumpscare 😭

🌈 SEE ALSO 🌈

Kernel file ./tools/include/linux/overflow.h, plus these iconic siblings: array_size(9), array3_size(9), struct_size(9) 🫢


and that's the whole vibe, fr fr ✨ this page came from ./tools/include/linux, dated October 2026 β€” slay, go forth and multiply (safely) πŸ’œπŸŽ€

πŸ“¦ where this page comes from