buffer_init_free(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

πŸ’… buffer_init_free(3) β€” straight outta the Library Functions Manual

okay bestie sit down because we're doing buffer allocation today and it's actually so cute. this whole page lives in section 3 of the Library Functions Manual, and it's giving short but iconic ✨


🌸 NAME 🌸

buffer_init_free β€” initialize buffer structure 🫢

like... that's it. that's the job. she initializes. she's a buffer struct starter pack.


✨ SYNTAX ✨

first, you gotta let her in the door:

#include <libowfat/buffer.h>

then the actual call:

void buffer_init_free(buffer &b,
                ssize_t (*op)(int,char*,size_t),
                int fd, char* y, size_t ylen);

no cap, that's the whole signature. b is your buffer, op is the callback with that (int,char*,size_t) shape, fd is a file descriptor, and y + ylen are your memory and its length πŸ’–


πŸ’œ DESCRIPTION πŸ’œ

so buffer_init_free is literally buffer_init's twin sister. same energy, same vibes, same everything...

EXCEPT β€” and this is the main character plot twist β€” the memory pointed to by y is marked to be freed by buffer_close() πŸ‘‘

that's it. that's the difference. buffer_init_free says "yeah bestie, this memory is mine now, buffer_close() is gonna handle it." so don't you dare go freeing y yourself, that's not your job anymore, that's buffer_close()'s moment πŸ’…

⚠️ lowkey important: the whole point is that y gets marked for freeing by buffer_close(). that's the only thing that separates her from buffer_init. don't lose the plot πŸŽ€

πŸ¦‹ SEE ALSO πŸ¦‹

  • buffer_init(3) β€” the sibling she's literally described in terms of, go read her
  • buffer_mmap_read(3) β€” different vibe, also a buffer thing
  • buffer(3) β€” the main hub, the mothership, the whole lore 🌈

and that's the tea, bestie πŸ“ this lil masterpiece is buffer_init_free(3), hanging out in the Library Functions Manual, being short, being sweet, being exactly like buffer_init except for that one glorious free-the-memory detail. go forth and initialize responsibly πŸ’–βœ¨πŸŽ€