VistaIONewString(3)

✨ VistaIONewString(3) ✨

okay bestie, so this is a page from the Library Functions Manual and it's about one little macro that is genuinely so useful you'll be obsessed πŸ’–


🌸 NAME 🌸

VistaIONewString β€” allocate a copy of a string πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <vistaio.h>

VistaIOString VistaIONewString (string)
       VistaIOString string;

πŸ’… ARGUMENTS πŸ’…

  • string β€” a null-terminated string, that's it, that's the whole vibe ✨

πŸ’– DESCRIPTION πŸ’–

So basically VistaIONewString copies a string into a newly-allocated block of memory, and it gets that memory by calling VistaIOMalloc(3). It's not doing anything wild β€” it's a convenience macro, a little bestie that does the boring part for you. Under the hood it calls VistaIOMalloc(3) with exactly these arguments, no cap:

(strcpy (VistaIOMalloc (strlen (string) + 1), string))

Like, it literally asks for strlen (string) + 1 bytes (the +1 is the null terminator, she's thorough πŸ’…) and then strcpys your string right in there. iconic behavior.


⭐ RETURN VALUES ⭐

VistaIONewString returns a pointer to the new copy of the string. fresh copy, no strings attached (well, one string attached, the copy) 🫢


🌈 SEE ALSO 🌈

go read those too, iykyk πŸ’œ


😭 DIAGNOSTICS 😭

If there is insufficient memory to allocate the new block, VistaIONewString terminates β€” like, full on stops existing β€” by calling VistaIOError(3) with the message `Out of memory`. so if you see that, bestie, your RAM said no πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Art Pope <pope@cs.ubc.ca>

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


🧚 ACKNOWLEDGMENT 🧚

This macro 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. giving credit where credit is due, periodt ✨


and that's the whole page, bestie!! this one came from VistaIO Version 1.2.14, dated 24 April 1993 β€” vintage but still slaying πŸŽ€πŸ’– mwah, go forth and copy some strings πŸ¦‹