iob_init(3)
β¨ iob_init(3) β¨
okay bestie, sit down, hydrate, and let me tell you about iob_init_autofree from the Library Functions Manual π this is the lil function that sets up a whole new I/O batch for you, with the autofree flag already flipped on. main character energy fr fr π
πΈ NAME πΈ
iob_init_autofree β initialize a new I/O batch, but make it autofree π
π¦ SYNTAX π¦
#include <libowfat/iob.h>
int iob_init_autofree(io_batch* b,size_t hint_entries);
β¨ DESCRIPTION β¨
So basically, iob_init_autofree initializes *b and allocates enough space for hint_entries entries, where an entry is a buffer or a file. π«Ά
hint_entries is purely a performance hint, no cap. If you're not sure what number to give it, just pass 1 and move on with your day. iykyk π
The autofree flag gets set by this one. That means your resources get freed inside iob_send once they've actually been sent out β not just when you finally call iob_reset or iob_free at the end. π but listen: you still have to call those. Autofree only frees the resources to be sent in the batch, not the resources of the batch itself. Two different things, don't get it twisted. π
You can add buffers, strings and files to an I/O batch and then send the whole thing at once with iob_send. one big slay, one go β¨
The whole point of the I/O batch API is that it exploits platform specific APIs, like FreeBSD's sendfile. π
- The file contents will always be sent in a way that lets the operating systems do zero copy TCP.
- The buffers will always be sent using as few syscalls as possible, while avoiding unnecessary copying (using
writev).
no cap, that's the vibe check it's passing π
π RETURN VALUE π
iob_initreturns0on success. β¨- If there was a memory allocation error, it returns
-1instead. π
π SEE ALSO π
iob_new(3)iob_init_autofree(3)iob_reset(3)iob_send(3)iob_addbuf(3)iob_adds_free(3)iob_addfile(3)
okay that's the whole thing, you ate it π this was iob_init(3) out of the Library Functions Manual, brought to you by the fine folks shipping libowfat. go forth and batch your I/O, bestie β periodt. ππ¦πΈ
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- 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