vrb_put(3)

πŸ“¦ version 0.5.1, in nixos 26.05

πŸ’– vrb_put(3) β€” the VRB Programmer's Manual, bestie edition πŸ’–

okay so real talk, this is vrb_put(3) from the VRB Programmer's Manual, and it's genuinely one of the most useful little functions in the whole -lvrb library. like, this is the one that actually puts stuff in. main character energy fr fr. πŸŽ€


✨ NAME ✨

vrb_put β€” put data into a VRB 🫢

πŸ“š LIBRARY πŸ“š

-lvrb

(she lives there. that's her house. link her in, king.)

🧚 SYNOPSIS 🧚

#include <vrb.h>

size_t vrb_put(vrb_p vrb, char *source, size_t size);

like look at her. three args, one return, no drama. we love a low-maintenance icon. πŸ‘‘

🌸 DESCRIPTION 🌸

vrb_put puts caller-provided data into a virtual ring buffer. that's the whole vibe. ✨

but here's the important part, so listen up: if there's less space available in the virtual ring buffer than the amount you're trying to put in, then only as much as can be fit will actually get copied. she doesn't throw a tantrum, she doesn't overflow, she just copies what fits and moves on. lowkey the most emotionally mature function in the library. πŸ¦‹

ngl, this is the one you gotta watch β€” she won't tell you she ran out of room except through her return value, so check it. πŸ™ˆ

πŸ’… ARGUMENTS πŸ’…

  • vrb_p vrb β€” specifies which virtual ring buffer. like, which one. there are many VRBs out there, bestie, you gotta say which.
  • char *source β€” specifies the location where to copy the data from. this is where your data is currently chilling before it gets moved into the ring buffer.
  • size_t size β€” specifies the length of data provided by the caller. i.e. how much you're bringing to the party. πŸŽ‰

πŸ”₯ RETURN VALUE πŸ”₯

size_t

the actual length of data copied gets returned. and it can be any value from 0 to the specified size β€” so like, 0 is a completely valid answer (she copied nothing, and she's not sorry), and size means you got everything in. anything in between means she ran out of space partway. so check it. always check it. fr fr. 😭

πŸ’€ ERRORS πŸ’€

if an error is returned, then errno will have this value:

  • EINVAL β€” an invalid virtual ring buffer pointer was specified. you handed her a bogus vrb pointer and she's like "girl what is this". not the vibe. πŸ’€

🌈 SEE ALSO 🌈

okay this is the whole squad, the entire friend group, no one gets left out:

vrb(3), vrb_capacity(3), vrb_data_len(3), vrb_data_ptr(3), vrb_destroy(3), vrb_get(3), vrb_get_min(3), vrb_give(3), vrb_init(3), vrb_init_opt(3), vrb_is_empty(3), vrb_is_full(3), vrb_is_not_empty(3), vrb_is_not_full(3), vrb_move(3), vrb_new(3), vrb_new_opt(3), vrb_put_all(3), vrb_read(3), vrb_read_min(3), vrb_resize(3), vrb_space_len(3), vrb_space_ptr(3), vrb_take(3), vrb_uninit(3), vrb_write(3), vrb_write_min(3)

like, go read vrb_put_all(3) next if vrb_put's "only copy what fits" behaviour is stressing you out. iykyk. πŸ§šβ€β™€οΈ


and that's the page!! this one's from the vrb manual, dated 2002-09-30, and it's vrb_put(3) all day long. slay, protect your ring buffer, and don't forget to check that return value. periodt. πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from