Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.0 KB
|
Line | |
---|
1 | /* |
---|
2 | FUNCTION |
---|
3 | <<wcsdup>>---wide character string duplicate |
---|
4 | |
---|
5 | INDEX |
---|
6 | wcsdup |
---|
7 | INDEX |
---|
8 | _wcsdup_r |
---|
9 | |
---|
10 | SYNOPSIS |
---|
11 | #include <wchar.h> |
---|
12 | wchar_t *wcsdup(const wchar_t *<[str]>); |
---|
13 | |
---|
14 | #include <wchar.h> |
---|
15 | wchar_t *_wcsdup_r(struct _reent *<[ptr]>, const wchar_t *<[str]>); |
---|
16 | |
---|
17 | DESCRIPTION |
---|
18 | <<wcsdup>> allocates a new wide character string using <<malloc>>, |
---|
19 | and copies the content of the argument <[str]> into the newly |
---|
20 | allocated string, thus making a copy of <[str]>. |
---|
21 | |
---|
22 | RETURNS |
---|
23 | <<wcsdup>> returns a pointer to the copy of <[str]> if enough |
---|
24 | memory for the copy was available. Otherwise it returns NULL |
---|
25 | and errno is set to ENOMEM. |
---|
26 | |
---|
27 | PORTABILITY |
---|
28 | POSIX-1.2008 |
---|
29 | |
---|
30 | QUICKREF |
---|
31 | wcsdup |
---|
32 | */ |
---|
33 | |
---|
34 | #include <reent.h> |
---|
35 | #include <stdlib.h> |
---|
36 | #include <wchar.h> |
---|
37 | |
---|
38 | wchar_t * |
---|
39 | _wcsdup_r (struct _reent *p, const wchar_t *str) |
---|
40 | { |
---|
41 | size_t len = wcslen (str) + 1; |
---|
42 | wchar_t *copy = _malloc_r (p, len * sizeof (wchar_t)); |
---|
43 | if (copy) |
---|
44 | wmemcpy (copy, str, len); |
---|
45 | return copy; |
---|
46 | } |
---|
47 | |
---|
48 | #ifndef _REENT_ONLY |
---|
49 | |
---|
50 | wchar_t * |
---|
51 | wcsdup (const wchar_t *str) |
---|
52 | { |
---|
53 | return _wcsdup_r (_REENT, str); |
---|
54 | } |
---|
55 | |
---|
56 | #endif /* !_REENT_ONLY */ |
---|
Note: See
TracBrowser
for help on using the repository browser.