TLSRPT_SET_MALLOC_AND_FREE(3)

πŸ’– TLSRPT_SET_MALLOC_AND_FREE πŸ’–

okay bestie, so this page is tlsrpt_set_malloc_and_free from section 3 of the manual (that's the C library functions girlies πŸŽ€), and it's lowkey one of those tiny functions that does one very specific thing and does it slay. let's get into it ✨


✨ NAME ✨

tlsrpt_set_malloc_and_free β€” swaps out the malloc implementation that libtlsrpt uses inside itself 🫢


🌸 SYNOPSIS 🌸

#include <tlsrpt.h>

void tlsrpt_set_malloc_and_free(void* (*malloc_function)(size_t size),
void (*free_function)(void *ptr))

yes she takes two function pointers and yes that signature is a whole vibe. copy it exactly, don't freestyle it πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the way that tlsrpt_set_malloc_and_free works is: it replaces the malloc implementation used within libtlsrpt. within, okay? not everywhere. the replaced malloc gets used inside libtlsrpt for exactly two things β€” allocating the struct tlsrpt_connection_t and the struct tlsrpt_dr_t structures. that's it. that's the whole list. πŸ“‹βœ¨

and literally none of the other malloc calls from inside the C standard library are affected. nope, not those. they stay doing their own thing πŸ™ˆ

⚠️ okay this is the important part, do not scroll past it ⚠️
this function must be called before any of the allocating functions β€” that means tlsrpt_open and tlsrpt_init_delivery_request β€” get called! because if you don't, you end up with one malloc implementation trying to free a pointer that a different malloc implementation allocated. and that is a whole mess, bestie. that's a πŸ’€ situation. it's giving chaos and not the fun kind.

πŸ‘‘ RETURN VALUE πŸ‘‘

tlsrpt_set_malloc_and_free has no return value. nothing to check, nothing to unwrap, she's just void. periodt. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

  • man:tlsrpt_open[3]
  • man:tlsrpt_init_delivery_request[3]

go read those two, they're the ones that actually allocate stuff and the ones you need to call this function before, iykyk 😌


🌈 AUTHOR 🌈

Boris Lohner β€” thank you for your service king 🫑✨


and that's the page!! this was tlsrpt_set_malloc_and_free, dated 2026-05-12, living in section TLSRPT_SET...C_AND_FREE(3) of the manual β€” go call it before you allocate anything or regret it forever πŸ’–πŸ§šβ­

πŸ“¦ where this page comes from