Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6557 serge 1
/*
2
FUNCTION
3
	<>---wide character string duplicate
4
 
5
INDEX
6
	wcsdup
7
INDEX
8
	_wcsdup_r
9
 
10
ANSI_SYNOPSIS
11
	#include 
12
	wchar_t *wcsdup(const wchar_t *<[str]>);
13
 
14
	#include 
15
	wchar_t *_wcsdup_r(struct _reent *<[ptr]>, const wchar_t *<[str]>);
16
 
17
TRAD_SYNOPSIS
18
	#include 
19
	wchar_t *wcsdup(<[ptr]>, <[str]>)
20
	struct _reent *<[ptr]>;
21
	wchar_t *<[str]>;
22
 
23
DESCRIPTION
24
	<> allocates a new wide character string using <>,
25
	and copies the content of the argument <[str]> into the newly
26
	allocated string, thus making a copy of <[str]>.
27
 
28
RETURNS
29
	<> returns a pointer to the copy of <[str]> if enough
30
	memory for the copy was available.  Otherwise it returns NULL
31
	and errno is set to ENOMEM.
32
 
33
PORTABILITY
34
POSIX-1.2008
35
 
36
QUICKREF
37
	wcsdup
38
*/
39
 
40
#include 
41
#include 
42
#include 
43
 
44
wchar_t *
45
_wcsdup_r (struct _reent *p, const wchar_t *str)
46
{
47
  size_t len = wcslen (str) + 1;
48
  wchar_t *copy = _malloc_r (p, len * sizeof (wchar_t));
49
  if (copy)
50
    wmemcpy (copy, str, len);
51
  return copy;
52
}
53
 
54
#ifndef _REENT_ONLY
55
 
56
wchar_t *
57
wcsdup (const wchar_t *str)
58
{
59
  return _wcsdup_r (_REENT, str);
60
}
61
 
62
#endif /* !_REENT_ONLY */