FMT_COPYBYTES_SIZEOF_MINUS1(3)
β¨ fmt_copybytes_sizeof_minus1 β¨
okay bestie, we're in the Library Functions Manual section 3 today and the star of the show is literally called fmt_copybytes_sizeof_minus1 π
she's a mouthful but she's iconic
π NAME π
fmt_copybytes_sizeof_minus1 β write binary data π¦
πΈ SYNTAX πΈ
#include <libowfat/fmt.h>
size_t fmt_copybytes_sizeof_minus1(char *dest,const char *source);
π DESCRIPTION π
okay so listen. this macro copies sizeof(source)-1 bytes from source into dest. that's it, that's the whole vibe β¨
it's giving convenience wrapper energy β a lil interface around fmt_copybytes for when you're building a binary message by smashing together hex constant strings, like this:
fmt_copybytes_sizeof_minus1(dest, "\x01\x02\x03\x04");
now here's the tea β because source is technically a string, the compiler sneaks a 0 byte onto the end, and sizeof() will hand you the size including that lil 0 byte. which is rude. so that's literally why there's a minus 1 in this function β so we do NOT copy it and we do NOT count it. problem solved, periodt π«Ά
π NOTE π
β οΈ Caution bestie: source must not have side effects, or those side effects will be evaluated twice. no cap, be careful π
π SEE ALSO π
that's the whole page fr fr β sending you love from the Library Functions Manual, section 3, where fmt_copyby...zeof_minus1(3) lives rent free ππ go forth and copy those bytes, you got this π§
π¦ 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
- 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 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