libwget-xalloc(3)

✨ libwget-xalloc ✨

okay so bestie, welcome to libwget-xalloc(3) πŸ’– this one lives in the Library Functions Manual section, and it's literally all about memory allocation functions. yes, malloc-and-friends core. it's giving backstage pass to how wget2 gets its memory πŸŽ€


πŸ¦‹ NAME πŸ¦‹

libwget-xalloc β€” Memory allocation functions πŸ’…


🌸 SYNOPSIS 🌸

✨ Variables ✨

like, here's the whole squad of global function pointers, defaults and all πŸ‘‘

wget_malloc_function * wget_malloc_fn = malloc
wget_calloc_function * wget_calloc_fn = calloc
wget_realloc_function * wget_realloc_fn = realloc
wget_free_function * wget_free = free

and the exported versions, with their API glow-up ✨

WGETAPI wget_malloc_function * wget_malloc_fn
WGETAPI wget_calloc_function * wget_calloc_fn
WGETAPI wget_realloc_function * wget_realloc_fn
WGETAPI wget_free_function * wget_free
RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT size_t size
#define wget_xfree(a)

the typedefs, aka the ~types~ of the function crew πŸ’œ

  • typedef void * wget_malloc_function(size_t) β€” Type of malloc() function.
  • typedef void * wget_calloc_function(size_t, size_t) β€” Type of calloc() function.
  • typedef void * wget_realloc_function(void *, size_t) β€” Type of realloc() function.
  • typedef void wget_free_function(void *) β€” Type of free() function.

and the inline wrappers, with all their attribute drama πŸ’…

RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE (1)
    WGET_GCC_MALLOC static inline void *NULLABLE wget_malloc(size_t
    size)
RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE2 (1, 2)
    WGET_GCC_MALLOC static inline void *NULLABLE wget_calloc(size_t
    nmemb
RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE (2)
    static inline void *NULLABLE wget_realloc(void *ptr

🌈 Detailed Description 🌈

okay so the whole vibe here: these are global function pointers to memory allocation functions and to free(). 🫢

and the fun part? these pointers can be set to custom functions. yes bestie, you get to swap them out. main character energy fr fr πŸ‘‘


πŸŽ€ Macro Definition Documentation πŸŽ€

πŸ’– #define wget_xfree( a) πŸ’–

Value:

do { if (a) { wget_free((void *)(a)); a=NULL; } } while (0)

Memory allocation function pointers ✨ (that's the whole tagline, no cap)


🧚 Variable Documentation 🧚

⭐ RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT size_t size ⭐

Initial value:

{
    return wget_calloc_fn(nmemb, size)

πŸ’« Author πŸ’«

Generated automatically by Doxygen for wget2 from the source code. πŸ€–βœ¨ (not me being jealous of an autogenerated author credit, it's giving lowkey iconic)


ngl bestie, the one thing to remember: these are pointers you're allowed to point somewhere else. swap responsibly πŸ’…

okay that's the whole page, and just so you know where it came from β€” this one's wget2, Version 2.3.0, and it's page libwget-xalloc(3) of the Library Functions Manual. mwah, go forth and allocate πŸ“πŸ’–

πŸ“¦ where this page comes from