LibC: Implement wcsdup
This commit is contained in:
parent
7a44c11378
commit
8eca395e4c
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/8eca395e4c9 Pull-request: https://github.com/SerenityOS/serenity/pull/11320 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 15 additions and 0 deletions
|
@ -61,6 +61,20 @@ wchar_t* wcscpy(wchar_t* dest, const wchar_t* src)
|
|||
return original_dest;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsdup.html
|
||||
wchar_t* wcsdup(const wchar_t* str)
|
||||
{
|
||||
size_t length = wcslen(str);
|
||||
wchar_t* new_str = (wchar_t*)malloc(sizeof(wchar_t) * (length + 1));
|
||||
|
||||
if (!new_str) {
|
||||
errno = ENOMEM;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return wcscpy(new_str, str);
|
||||
}
|
||||
|
||||
wchar_t* wcsncpy(wchar_t* dest, const wchar_t* src, size_t num)
|
||||
{
|
||||
wchar_t* original_dest = dest;
|
||||
|
|
|
@ -28,6 +28,7 @@ struct tm;
|
|||
|
||||
size_t wcslen(const wchar_t*);
|
||||
wchar_t* wcscpy(wchar_t*, const wchar_t*);
|
||||
wchar_t* wcsdup(const wchar_t*);
|
||||
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
|
||||
__attribute__((warn_unused_result)) size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
|
||||
int wcscmp(const wchar_t*, const wchar_t*);
|
||||
|
|
Loading…
Add table
Reference in a new issue