array_truncate(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– array_truncate β€” the manual page, bestie edition πŸ’–

okay so this is array_truncate(3) from the Library Functions Manual and it's literally the glow-down your array asked for ✨


✨ NAME ✨

array_truncate β€” reduce number of initialized bytes πŸŽ€


🌸 SYNTAX 🌸

#include <libowfat/array.h>

void array_truncate(array* x, uint64 membersize, int64 len);

  array_truncate(&x,sizeof(t),len);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: your array x has been out here living its best life, all these initialized bytes, and you're like… bestie, we need to cut. array_truncate reduces the number of initialized bytes in x to exactly len*sizeof(t). iconic. no cap. πŸ’…

and here's the part where it's lowkey the chillest function ever, because it does literally nothing in like four whole situations:

  • if the number of initialized bytes was already this small (or smaller) β€” no effect 🫢
  • if len is negative β€” no effect 🫢
  • if x is unallocated β€” no effect 🫢
  • if x has failed β€” no effect 🫢

like, it's giving "I'm not gonna make it worse, I'm just gonna not do anything." main character energy, honestly. πŸ’€

IMPORTANT: array_truncate does not change the allocation in x. nope. the memory is still there, still vibing, still yours. so if you actually want to free the memory used by x, you need to go use array_reset instead. different function, different vibe, don't mix them up bestie 😭


🌈 SEE ALSO 🌈


and that's the whole page fr fr πŸ“ this was array_truncate(3) hanging out under the Library Functions Manual banner, and yes the footer is just the name again because the manpage said so and we respect the manpage πŸ‘‘ go forth and truncate responsibly, bestie πŸ§šπŸ’œ