tcp_malloc(3)
πΈ tcp_malloc β z88dk Programmer's Manual, section 3 π
okay bestie, so this is the manual page for tcp_malloc(3) from the z88dk Programmer's Manual and it's genuinely giving "tiny memory allocator that lives inside a network stack" energy and honestly? iconic. sit down, hydrate, let's get into it π«Ά
β¨ NAME β¨
tcp_calloc, tcp_malloc, tcp_free β allocate and free memory π
β¨ SYNOPSIS β¨
#include <net/misc.h>
void *tcp_calloc(size_t nmemb, size_t size);
void *tcp_malloc(size_t size);
void tcp_free(void *ptr);
like, that's the whole vibe. three little functions. pull in the header and you're in business β¨
β¨ DESCRIPTION β¨
calloc() allocates memory for an array of nmemb elements of size bytes each, and hands you back a pointer to that allocated memory. the memory is set to zero β no cap, it literally zeroes it for you. π
malloc() allocates size bytes and returns a pointer to the allocated memory. the memory is not cleared, so bestie, it's whatever was in there before. not your business, don't look at it π
free() frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc() or calloc(). otherwise? or if free(ptr) has already been called before? undefined behaviour. not "weird results", not "maybe it's fine" β undefined, as in the compiler is allowed to do crimes. π if ptr is NULL, no operation is performed. chill. nothing happens. π
β¨ RETURN VALUES β¨
for calloc() and malloc(), what you get back is a pointer to the allocated memory, and it's suitably aligned for any kind of variable (slay, alignment queens π), or NULL if the request fails π.
free() returns no value. it just. frees. no receipt, no nothing. π
β¨ SEE ALSO β¨
tcp_pagein(3z)tcp_pageout(3z)
β¨ NOTES β¨
so here's the lore, bestie π§ these functions manipulate memory in a private memory page belonging to ZSock. this 16k page holds all the buffers that ZSock uses, which means requests for large amounts of memory are likely to fail β and in any case, they are not recommended. fr fr, don't do it.
this facility has been offered to allow daemons to be written easily (they have no address space of their own). user applications should not use these facilities. if a large (>256 bytes) amount of memory is required for a user application then the application should either be of the BAD type or be redesigned. that's not me being mean, that's literally what the page says. π«Ά
so like: daemons only. user apps, back away slowly. main character energy is for the daemons here, not you π
β¨ AUTHOR β¨
Dominic Morris <dom@jb.man.ac.uk> β thank you for your service πβ¨
and that's the whole page babes π this gem is dated February 18 2000 and it ships with the z88dk Programmer's Manual β yes, our girl has been out here allocating and freeing since Y2K and she's still serving looks. periodt. π πΈ
π¦ where this page comes from
- fedora 43: z88dk 1.10.1-33.20150709cvs.fc43 Β· ClArtistic
- fedora 44: z88dk 1.10.1-33.20150709cvs.fc43 Β· ClArtistic
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms