wcsdup(3)
β¨ wcsdup(3) β¨
okay bestie, so this is <wchar.h>'s resident copycat β the wide-character glow-up of strdup(3). π
πΈ NAME πΈ
wcsdup β duplicate a wide-character string π¦
π LIBRARY π
Standard C library (libc, -lc) β the O.G. one you already link against, no cap.
β¨ SYNOPSIS β¨
#include <wchar.h>
wchar_t *wcsdup(const wchar_t *s);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)) π
wcsdup():
- Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
- Before glibc 2.10:
_GNU_SOURCE
Like, if you're on ancient glibc and this won't compile, it's giving "you forgot _GNU_SOURCE". iykyk π
π DESCRIPTION π
The wcsdup() function is literally the wide-character equivalent of the strdup(3) function β same vibe, wider chars. It allocates and returns a new wide-character string whose initial contents is a duplicate of the wide-character string pointed to by s. π«Ά
Memory for the new wide-character string is obtained with malloc(3), and should be freed with free(3). No leaking, bestie β that's not the main character energy we're going for. π§
π¨ reminder: it'smalloc'd, so it's yours.free(3)it when you're done or it's just gonna sit there in your heap forever like an unread group chat. π
π RETURN VALUE π
On success, wcsdup() returns a pointer to the new wide-character string. Slay.
On error, it returns NULL, with errno set to indicate the error. Check it. Please. π
π ERRORS π
ENOMEMβ Insufficient memory available to allocate duplicate string. The malloc said no. π
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
wcsdup()β Thread safety: MT-Safe β
Thread safe babyyy, MT-Safe, you can call it from multiple threads and it will simply not be the drama. π₯
β STANDARDS β
POSIX.1-2008. Periodt. Certified. π
π°οΈ HISTORY π°οΈ
libc5, glibc 2.0 β so it's been here since basically forever, an icon, a legend. π
π SEE ALSO π
k bye, love u, go free your strings π«Ά β this page came to you from Linux man-pages 6.20, dated 2026-02-08, and it's wcsdup(3) fr fr. πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms