ustrdup(3alleg4)

πŸ¦‹ NAME πŸ¦‹

ustrdup β€” duplicates a string. From the Allegro game programming library, aka the 3alleg4 manual bestie, we been knew πŸ’…


✨ SYNOPSIS ✨

#include <allegro.h>

char *ustrdup(const char *src)

🌸 DESCRIPTION 🌸

okay so. this function takes the null-terminated string src and copies it into a freshly allocated chunk of memory β€” like, brand new, nobody else's, all yours. it's literally duplicating the string fr fr 🫢

here's the vibe in action:

void manipulate_string(const char *input_string)
{
   char *temp_buffer = ustrdup(input_string);
   /* Now we can modify temp_buffer */
   ...

see how temp_buffer is a whole separate copy? that's the whole point, no cap. you can do whatever you want to it and the original stays untouched, icon that she is πŸ‘‘


πŸ’– RETURN VALUE πŸ’–

she hands you back the newly allocated string ✨ β€” and like, the caller has to free that memory, that's on you bestie, don't just leave her hanging 😭

and if she can't allocate space for the duplicated string? you get NULL. that's it. that's the tea πŸ’€


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, babe 🧚 this was Allegro, version 4.4.3, and yes the ustrdup(3alleg4) girlies ate this one up. go free your strings, mwah πŸ’œ