TT_MALLOC(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

πŸ’… tt_malloc β€” library call, bestie

okay so this is the tt_malloc page from the library call section, and it's literally one function, so let's get into it 🫢


✨ NAME ✨

tt_malloc β€” allocate storage on the ToolTalk API allocation stack

like, it grabs you some bytes, but make it ~ToolTalk~ πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <Tt/tt_c.h>
caddr_t tt_malloc(
size_t s);

yes bestie, that's the whole thing. one include, one call, one size_t. clean. iconic. periodt ✨


🌸 DESCRIPTION 🌸

so the tt_malloc function allocates storage on the ToolTalk API allocation stack. that's the vibe. that's what it does. no cap 🧚

the s argument is the amount of storage to be allocated, in bytes. that's it β€” just tell it how many bytes you need and it handles the rest on that allocation stack πŸ’œ


πŸ¦‹ RETURN VALUE πŸ¦‹

upon successful completion, the tt_malloc function returns the address of the storage in the ToolTalk API allocation stack that is to be allocated πŸ’…

but β€” and this is the part where you pay attention β€” if NULL is returned, no storage is available. like, none. zero. not a single byte 😭 so please check it, k? i'm begging πŸ™ˆ


🌈 APPLICATION USAGE 🌈

okay so this function is the whole reason your application-provided callback routines get to take advantage of the allocation stack πŸ‘‘

for example β€” and this is fr fr the example β€” a query filter function can allocate storage to accumulate a result. so like, your filter callback is out here collecting results and it needs somewhere to put them, and tt_malloc is right there for it πŸ“

it's giving main character energy for callbacks, honestly πŸ’€


⭐ SEE ALSO ⭐

(you're gonna want tt_free(3), bestie β€” what goes on the allocation stack does not stay on the allocation stack forever 😌)


little reminder: this page doesn't tell you what to do with the pointer after you're done β€” that's what tt_free(3) is for. go read it, iykyk πŸ’–

okay that's the whole page! 🌟 it's the tt_malloc(library call) page, and the footer had zero extra lore β€” no version stamp, no date, just tt_malloc(library call) again, so like... the page said its own name twice and dipped πŸ’€ slay, honestly. byeee πŸŽ€πŸ’œ

πŸ“¦ where this page comes from