types.h(3)
π types.h(3) β the Brotli types era π
okay bestie, so this is a page from the Library Functions Manual, and it's all about types.h β the lil header that holds the common types used in the decoder and encoder API. yes, it's header-file lore, and yes, it's iconic. π
β¨ NAME β¨
types.h β Common types used in decoder and encoder API.
πΈ SYNOPSIS πΈ
π¦ Macros
#define BROTLI_BOOLintβ A portable bool replacement.#define BROTLI_FALSE0β Portable false replacement.#define BROTLI_TRUE1β Portable true replacement.#define TO_BROTLI_BOOL(X)(!!(X) ? BROTLI_TRUE : BROTLI_FALSE)β bool to BROTLI_BOOL conversion macros.
π¦ Typedefs
typedef void *(* brotli_alloc_func) (void *opaque, size_t size)β Allocating function pointer type.typedef void(* brotli_free_func) (void *opaque, void *address)β Deallocating function pointer type.
π Detailed Description π
Common types used in decoder and encoder API.
like. that's the whole vibe. common types. decoder AND encoder. she contains multitudes. β¨
π Macro Definition Documentation π
#define BROTLI_BOOL int
A portable bool replacement. BROTLI_BOOL is a 'documentation' type: actually it is int, but in API it denotes a type, whose only values are BROTLI_TRUE and BROTLI_FALSE.
no cap, it's literally an int wearing a bool costume. it's giving main character energy but underneath it's just int. π
BROTLI_BOOL values passed to Brotli should either be BROTLI_TRUE or BROTLI_FALSE, or be a result of TO_BROTLI_BOOL macros.
bestie listen. do NOT just yeet a random int in there. it'sBROTLI_TRUE,BROTLI_FALSE, or aTO_BROTLI_BOOLresult. that's the whole menu. π
BROTLI_BOOL values returned by Brotli should not be tested for equality with true, false, BROTLI_TRUE, BROTLI_FALSE, but rather should be evaluated, for example:
if (SomeBrotliFunction(encoder, BROTLI_TRUE) &&
!OtherBrotliFunction(decoder, BROTLI_FALSE)) {
bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4));
DoSomething(x);
}
so the way that you should do it: just evaluate it. don't go == BROTLI_TRUE, don't go == true. just let it be true-ish in the if. slay. π«Ά
#define BROTLI_FALSE 0
Portable false replacement.
the girlies said "0" and honestly? correct. π
#define BROTLI_TRUE 1
Portable true replacement.
and the sequel is "1". ate. π₯
#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
bool to BROTLI_BOOL conversion macros.
the double-bang !! is the glow-up. it takes your whatever and turns it into a proper BROTLI_TRUE/BROTLI_FALSE. chef's kiss. πβ¨
π Typedef Documentation π
typedef void*(* brotli_alloc_func) (void *opaque, size_t size)
Allocating function pointer type.
Parameters:
opaqueβ custom memory manager handle provided by clientsizeβ requested memory region size; can not be 0
not me stressing that size can not be 0. fr fr, zero is not the move here. π
Returns:
0in the case of failure- a valid pointer to a memory region of at least
sizebytes long otherwise
so you either get nothing (a 0, which is the fail era) or a pointer to at least size bytes. at least. the queen gives you a little extra sometimes, and we love that for her. π
typedef void(* brotli_free_func) (void *opaque, void *address)
Deallocating function pointer type. This function SHOULD do nothing if address is 0.
like. if address is 0, the function SHOULD do nothing. that's the assignment. don't be out here freeing nothing. π
Parameters:
opaqueβ custom memory manager handle provided by clientaddressβ memory region pointer returned bybrotli_alloc_func, or0
iykyk β the address you pass in is the one brotli_alloc_func handed you, or 0. keep the receipts. π§
π Author π
Generated automatically by Doxygen for Brotli from the source code.
and that's the whole page, bestie!! this little types.h(3) situation came from Brotli, dated August 2021 β so if you ever need to cite her, that's the receipt. stay portable, stay evaluated-not-compared, and remember: BROTLI_BOOL is an int in a bool dress. periodt. ππΈβ¨
π¦ where this page comes from
- alpine 3.22: brotli-doc 1.1.1-r0 Β· MIT
- alpine 3.23: brotli-doc 1.2.1-r0 Β· MIT
- alpine 3.24: brotli-doc 1.2.1-r0 Β· MIT
- arch rolling: brotli 1.2.0-1
- arch rolling: brotli 1.2.1-1 Β· MIT
- nixos 26.05: brotli 1.2.1
- nixpkgs unstable: brotli 1.2.0
- opensuse-leap 16.0: libbrotli-devel 1.1.0-160000.2.2 Β· MIT
- opensuse-leap 16.0: libbrotli-devel 1.1.0-160000.2.2 Β· MIT
- opensuse-leap 16.0: libbrotli-devel 1.1.0-160000.2.2 Β· MIT
- opensuse-leap 16.0: libbrotli-devel 1.1.0-160000.2.2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms