range_ptrinbuf(3)
π range_ptrinbuf(3) π
okay bestie, so this one lives in the Library Functions Manual and it's lowkey one of those tiny functions that saves your whole entire program from vibing straight off a cliff π«Ά
β¨ NAME β¨
range_ptrinbuf β range check pointer in buffer π―
β¨ SYNTAX β¨
#include <libowfat/rangecheck.h>
int range_ptrinbuf(const void* buf,size_t len,const void* ptr);
β¨ DESCRIPTION β¨
so the whole girlboss job of range_ptrinbuf is literally just this: it checks if ptr points to buf[0..len-1]. that's it. that's the function. she's not doing your taxes, she's doing a vibe check on a pointer π
like... is this pointer actually inside the buffer, or is it out here living its truth in undefined-behaviour land? she'll tell you. no cap. β¨
β¨ RETURN VALUE β¨
she's giving a very simple yes/no situation, here's the tea:
- if the buffer is implausible β meaning
bufisNULL, orbuf+lenhas an integer overflow π β she returns0. - if
ptrpoints to one ofbuf[0],buf[1], ... orbuf[len-1], she returns1π - otherwise, she returns
0π
fr fr, that overflow case is the main character of this whole function. a buffer that wraps around is not a buffer, bestie, and she's not about to pretend otherwise.
β¨ SEE ALSO β¨
rangecheck(3)β her sister, go say hi πΈ
and that's the whole page, gorgeous π it's range_ptrinbuf(3) from the Library Functions Manual, and the footer said range_ptrinbuf(3) too, so... yeah she's literally signed her own name at the bottom, iconic behaviour honestly πβ¨ slay, go range check something π¦
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms