SOLDOUT_BUFFER(3)
π SOLDOUT_BUFFER π
okay bestie, gather round π«Ά this is SOLDOUT_BUFFER(3) from the Library Functions Manual β literally the entire buffer-handling situation for soldout. it's giving "my strings need somewhere cute to live" and honestly? it ate. no cap. π
β¨ NAME β¨
soldout_buffer, bufcasecmp, bufcmp, bufcmps, bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufput, bufputs, bufputc, bufrelease, bufreset, bufset, bufslurp, buftoi, vbufprintf β buffer handling functions for soldout πΈ
π SYNOPSIS π
#include <buffer.h>
#define CONST_BUF(name, string)
#define VOLATILE_BUF(name, strname)
#define BUFPUTSL(output, literal)
int
bufcasecmp(const struct buf *a, const struct buf *b);
int
bufcmp(const struct buf *a, const struct buf *b);
int
bufcmps(const struct buf *a, const char *b);
struct buf *
bufdup(const struct buf *src, size_t dupunit);
int
bufgrow(struct buf *buf, size_t sz);
struct buf *
bufnew(size_t unit);
void
bufnullterm(struct buf *buf);
void
bufprintf(struct buf *buf, const char *fmt, ...);
void
bufput(struct buf *buf, const void *data, size_t len);
void
bufputs(struct buf *buf, const char *str);
void
bufputc(struct buf *buf, char c);
void
bufrelease(struct buf *buf);
void
bufreset(struct buf *buf);
void
bufset(struct buf **dest, struct buf *src);
void
bufslurp(struct buf *buf, size_t len);
int
buftoi(struct buf *buf, size_t offset_i, size_t *offset_o);
void
vbufprintf(struct buf *buf, const char *fmt, va_list ap);
extern long buffer_stat_nb;
extern size_t buffer_stat_alloc_bytes;
π¦ DESCRIPTION π¦
π Variables
Compile time options. Statistics are kept about memory usage. πβ¨
buffer_stat_nbβ show how many buffers were created. she's counting, and she's keeping receipts π§Ύbuffer_stat_alloc_bytesβ show how many bytes were allocated. the receipts, but in bytes πΎ
πΈ Types
struct buf
character array buffer. Consists of the following fields:
char * dataβ actual character data. the real ones β¨size_t sizeβ size of the string. how much is actually in there πsize_t asizeβ allocated size (0 = volatile buffer). how much room she booked πsize_t unitβ reallocation unit size (0 = read-only buffer). how much she grows by when she needs more π¦int refβ reference count. how many besties are holding onto her π«Ά
π§ Macros
CONST_BUFβ create a global buffer name from a string literalstring. ποΈVOLATILE_BUFβ create a volatile buffer name on the stack from a stringstrname. π«§BUFPUTSLβ optimizedbufputs()of a string literal. speed, but make it β¨aestheticβ¨
π Functions
bufcasecmp()β compare two buffers ignoring case. not judgmental, just lowercase about it πbufcmp()β compare two buffers. who's bigger, bestie πbufcmps()β compare a buffer to a string. buffer vs. the literal πbufdup()β duplicate a buffersrc. twin energy, lowkey iconic π―bufgrow()β increase the allocated size to the given value. glow-up, but measured in bytes πbufnew()β create a new buffer. brand new baby, periodt βbufnullterm()β terminate the string array byNUL(making a C-string). closing the group chat properly πbufprintf()β print formatted output to a bufferbuf. formatted, so she's fancy πbufput()β append raw data to a bufferbuf. raw, unfiltered, no cap πΆοΈbufputs()β append aNUL-terminated stringstrto a bufferbuf. the classic move β¨bufputc()β append a single charcto a bufferbuf. one little letter, main character energy πbufrelease()β decrease the reference count and free the bufferbufif needed. letting her go when nobody's holding on anymore πbufreset()β free internal data of the bufferbuf. internal spring cleaning π§Ήbufset()β safely assign a buffer to another. handoff, but safe, no drama π«Άbufslurp()β remove a given number of bytes from the head of the array. slurp π bye bytesbuftoi()β convert the numbers at the beginning of the bufferbufinto anint. math era π’vbufprintf()βstdarg(3)variant of formatted printing into a bufferbuf. the va_list cousin ofbufprintf()π
π RETURN VALUES π
the bufcasecmp(), bufcmp() and bufcmps() functions return an integer less than, equal to, or greater than zero if a is found, respectively, to be less than, to match, or be greater than b. yes, three outcomes, she's flexible π
the bufdup() and bufnew() functions return a struct buf * on success; on error they return NULL. π§οΈ
the bufgrow() function returns on success 1; on error - 0. that's the whole vibe check β
the bufnullterm(), bufprintf(), bufput(), bufputs(), bufputc(), bufrelease(), bufreset(), bufset(), bufslurp() and vbufprintf() functions do not return a value. they just do the thing and leave π«₯β¨
the buftoi() function return the converted value. yes, "return", singular, we don't argue with the original π«Ά
π₯ SEE ALSO π₯
soldout(3), stdarg(3) β go read those too bestie, iykyk ππ
π AUTHORS π
the soldout library was written by Natasha "Kerensikova" Porte <natacha@instinctive.eu>. π
manual page was originally written by Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc format by Svyatoslav Mishyn <juef@openmailbox.org>. π
and that's the whole page, bestie π
this one shipped from Debian on April 13, 2016, and it's SOLDOUT_BUFFER(3) forever and always. slay, stay buffered, drink water π¦πβ¨
π¦ where this page comes from
- debian bookworm: libsoldout-dev 1.4-5 Β· ISC
- debian trixie: libsoldout-dev 1.4-7+b1 Β· ISC
- ubuntu jammy: libsoldout-dev 1.4-5 Β· ISC
- ubuntu noble: libsoldout-dev 1.4-5build1 Β· ISC
- ubuntu questing: libsoldout-dev 1.4-7
- ubuntu resolute: libsoldout-dev 1.4-7build1 Β· ISC
- ubuntu stonking: libsoldout-dev 1.4-7build1 Β· ISC
- Copyright (c) 2009 - 2016 Natacha PortΓ© <natacha@instinctive.eu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms