vrb_take(3)

πŸ“¦ version 0.5.1, in nixos 26.05

πŸ’… vrb_take(3) β€” the VRB Programmer's Manual, bestie edition ✨

okay so this one's from the VRB Programmer's Manual, and it's genuinely one of the most "you had to be there" little functions in the whole ring-buffer saga. it's the cleanup bestie. the "yes i took it, thank you" of the whole vibe. let's get into it 🫢


🌸 NAME

vrb_take β€” take data from a VRB πŸ’–

πŸŽ€ LIBRARY

-lvrb

✨ SYNOPSIS

#include <vrb.h>

vrb_p vrb_take(vrb_p vrb, size_t size);

πŸ’œ DESCRIPTION

so vrb_take is literally you telling the buffer "hey bestie, i took this much data out of your data section, k?"

here's the flow, iykyk: you already called vrb_data_len(3) and vrb_data_ptr(3) to get the length of the data in the buffer and a pointer to it. then you went and extracted some data from the buffer β€” starting from the pointer you got, and extracting no more than the length you got. and now you come back and call vrb_take to say how much you actually took. πŸ’…

it's giving "receipts". the buffer needs to know. don't leave it hanging 😭

πŸ¦‹ ARGUMENTS

  • vrb_p vrb β€” specifies which virtual ring buffer. like, which one. there are many. be specific πŸŽ€
  • size_t size β€” specifies the length of data that has been obtained from the virtual ring buffer by the caller. so like, the amount you stole. lovingly. from the buffer. πŸ‘‘

🌈 RETURN VALUE

int

on success, 0 is returned. on error, -1 is returned. that's it. that's the whole vibe check. ✨

πŸ”₯ ERRORS

if an error is returned, then errno will have one of the following values:

  • EINVAL β€” an invalid virtual ring buffer pointer was specified. you handed it a fake ID bestie πŸ’€
  • ENOSPC β€” the specified length is greater than the data in the virtual ring buffer. you're claiming you took more than there even was. not the flex you think it is πŸ™ˆ
fr fr, ENOSPC here means your size is bigger than the actual data sitting in the buffer β€” no cap, that's a mistake, not a mood.

πŸ‘‘ SEE ALSO

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(3), vrb_put_all(3), vrb_read(3), vrb_read_min(3), vrb_resize(3), vrb_space_len(3), vrb_space_ptr(3), vrb_uninit(3), vrb_write(3), vrb_write_min(3)


πŸ“ that's the whole page bestie. vrb Β· 2002-09-30 Β· vrb_take(3) β€” dated, iconic, still valid. mwah πŸ’‹πŸ§šβ€β™€οΈ
πŸ“¦ where this page comes from