WCSDUP(3P)

✨ WCSDUP(3P) ✨

okay bestie, gather round, because we're about to talk about wcsdup() β€” she's a POSIX Programmer's Manual girlie, and she is so much simpler than she sounds πŸ’–


🌸 PROLOG 🌸

Real talk first, no cap: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” so if you're on Linux, pls go consult the corresponding Linux manual page for the deets on Linux behavior. Or… the interface might not even be implemented on Linux at all 😭. Vibe check accordingly.


πŸ’… NAME πŸ’…

wcsdup β€” duplicate a wide-character string. that's it. that's the whole job. iconic.


πŸŽ€ SYNOPSIS πŸŽ€

#include <wchar.h>

wchar_t *wcsdup(const wchar_t *string);

πŸ¦‹ DESCRIPTION πŸ¦‹

So wcsdup() is literally just the wide-character equivalent of the strdup() function. Same energy, wider chars, periodt.

What she does: wcsdup() shall return a pointer to a new wide-character string, allocated as if by a call to malloc(), and that new string is the duplicate of the wide-character string string. The returned pointer can be passed to free() 🫢. And if the new wide-character string cannot be created? A null pointer is returned. sad but true.


🌈 RETURN VALUE 🌈

Upon successful completion, wcsdup() shall return a pointer to the newly allocated wide-character string. slay ✨

Otherwise β€” aka when things go wrong β€” it shall return a null pointer and set errno to indicate the error. so always check your errno, bestie, she's telling you what happened πŸ’€


πŸ”₯ ERRORS πŸ”₯

wcsdup() shall fail if:

  • ENOMEM β€” Memory large enough for the duplicate string could not be allocated. the malloc said no πŸ™ˆ

The following sections are informative. (yes really, everything after this is just vibes and context πŸ‘‘)


⭐ EXAMPLES ⭐

None. literally nothing here. she's self-explanatory. iykyk πŸ’…


πŸ’œ APPLICATION USAGE πŸ’œ

Okay so important rule for functions that allocate memory as if by malloc(): the application should release such memory when it is no longer required, by a call to free(). For wcsdup(), that memory is the return value. so like… free your girl when you're done with her, don't leave her hanging πŸ₯Ί


🧚 RATIONALE 🧚

None. no thoughts, head empty, she just works 🌸


πŸ“ FUTURE DIRECTIONS πŸ“

None. the future is bright and unchanging, bestie ✨


πŸ’– SEE ALSO πŸ’–

  • free()
  • strdup()
  • wcscpy()

The Base Definitions volume of POSIX.1‐2017, <wchar.h>


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! this one came from IEEE/The Open Group, dated 2017, and her manual name is WCSDUP(3P) πŸ’…πŸ¦‹ go forth and duplicate responsibly βœ¨πŸ’–

πŸ“¦ where this page comes from