OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [string/] [wcsdup.c] - Blame information for rev 345

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
        <<wcsdup>>---wide character string duplicate
4
 
5
INDEX
6
        wcsdup
7
INDEX
8
        _wcsdup_r
9
 
10
ANSI_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
TRAD_SYNOPSIS
18
        #include <wchar.h>
19
        wchar_t *wcsdup(<[ptr]>, <[str]>)
20
        struct _reent *<[ptr]>;
21
        wchar_t *<[str]>;
22
 
23
DESCRIPTION
24
        <<wcsdup>> allocates a new wide character string using <<malloc>>,
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
        <<wcsdup>> 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 <reent.h>
41
#include <stdlib.h>
42
#include <wchar.h>
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 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.