VistaIOMalloc(3)

πŸ’– VistaIOMalloc(3) β€” the memory girlies' manual page πŸ’–

okay bestie, so this is a page from the Library Functions Manual, and it's literally all about memory allocation. no cap. it's giving malloc but make it VistaIO. let's get into it 🫢


✨ NAME ✨

VistaIOMalloc, VistaIOCalloc, VistaIORealloc, VistaIOFree β€” memory allocation functions. yes queen, the whole squad πŸŽ€


🌸 SYNOPSIS 🌸

VistaIOPointer VistaIOMalloc (size_t size);

VistaIOPointer VistaIOCalloc (size_t num, size_t elsize);

VistaIOPointer VistaIORealloc (VistaIOPointer ptr, size_t size);

void VistaIOFree (VistaIOPointer ptr);

four functions, four signatures, all exact, all slay πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • size β€” the number of bytes you want, bestie. that's it, that's the vibe.
  • num β€” how many array elements you're asking for.
  • elsize β€” how big one array element is, in bytes.
  • ptr β€” a pointer to your old storage, OR a pointer to the block of storage that's getting freed. either way, it's the pointer in question πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

VistaIOMalloc

returns a pointer to a block of storage of at least size bytes. but here's the tea: it returns NULL if size is zero. zero bytes = no block, periodt.

VistaIOCalloc

allocates space for num array elements, each of size elsize, and initializes that space to zero bits. squeaky clean ✨. and like VistaIOMalloc, it returns NULL if you ask it to allocate zero space. zero is zero, no notes.

VistaIORealloc

changes a block of storage (the one ptr points to) to be of size size β€” and yeah, it might literally move it somewhere else, that's just how she rolls. if it needs to, it allocates a new block at a different location, copies the old contents (or as much as will fit 😭) into the new block, and then frees the old block. moving on up, main character energy.

  • if ptr is NULL, VistaIORealloc allocates the new storage without copying old contents β€” like, it's just calling VistaIOMalloc. same thing, different name.
  • if size is zero, it frees the storage pointed to by ptr and returns NULL.

VistaIOFree

frees storage, so it can be reused later. recycling queen 🌈. and if ptr is NULL, VistaIOFree has no effect β€” it just... does nothing. no drama, no crash, iconic.


⭐ RETURN VALUES ⭐

VistaIOMalloc, VistaIOCalloc, and VistaIORealloc each return a pointer to the allocated storage. every single time. that's the whole return value.

VistaIOFree does not return a value. it's a void, bestie, she gives nothing back and that's fine πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

malloc(3), VistaIONew(3), VistaIONewString(3), VistaIOError(3),

(yes the comma is staying, i don't make the rules πŸ’€)


πŸ’€ DIAGNOSTICS πŸ’€

if there is insufficient memory to allocate a requested block, VistaIOMalloc, VistaIOCalloc, or VistaIORealloc will terminate by calling VistaIOError(3) with the message ``Memory allocation failure''.

⚠️ bestie. this is not a soft little "oops, returned NULL" moment. it terminates. it calls VistaIOError(3). you do not pass go, you do not collect two hundred dollars. plan accordingly 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Art Pope <pope@cs.ubc.ca>

Adaption to vistaio: Gert Wollny <gw.fossdev@gmail.com>

thank you for your service, legends πŸ™Œ


🧚 ACKNOWLEDGMENT 🧚

these functions and this manual page are based on similar ones included in the X Toolkit Intrinsics, which is Copyright 1985, 1986, 1987, 1988 Massachusetts Institute of Technology, Cambridge, Massachusetts, and Digital Equipment Corporation, Maynard, Massachusetts. shoutout to the ancestors of this code, fr fr πŸŽ€


and that's the whole page, bestie!! this was VistaIO Version 1.2.14, dated 3 June 1994 β€” yes, 1994, she's vintage and she still hits different πŸ’–βœ¨ go forth and allocate responsibly, mwah πŸ’…πŸ¦‹