buffer_peek(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_peek(3) πŸ¦‹

okay bestie, sit down, hydrate, and let me tell you about buffer_peek β€” it lives in the Library Functions Manual and it is exactly the lowkey hero you want when you're reading stuff out of a buffer. πŸ’…


✨ NAME ✨

buffer_peek β€” return pointer to string in buffer 🌸


✨ SYNTAX ✨

first things first, you gotta pull in the header, no cap:

#include <libowfat/buffer.h>

char* buffer_peek(buffer* b);

✨ DESCRIPTION ✨

so here's the whole vibe: buffer_peek returns a pointer to the first byte of the string in the buffer. that's it. that's the function. it's giving "here, hold this pointer" and honestly? iconic. πŸ‘‘


✨ EXAMPLE ✨

not me about to show you the cutest little reading loop ever 🫢 β€” buffer_feed, buffer_peek and buffer_seek can be used together for efficient reading loops, nearly the same speed as calling op directly:

for (;;) {
  r = buffer_feed(&b);
  if (r <= 0) return r;
  x = buffer_peek(&b);
  dosomething(x,r);
  buffer_seek(&b,r);
}

look at that. peek, do the thing, seek. the trio ate and left no crumbs. πŸ”₯


✨ SEE ALSO ✨

go read these next, they're all part of the family πŸ’œ


and that's the whole page, babe 🌈 it's straight out of the Library Functions Manual, signed off at the bottom with buffer_peek(3) like the main character it is. periodt. πŸ’–