~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to cmd-line-utils/libedit/np/wcsdup.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $  */
 
2
 
 
3
/*
 
4
 * Copyright (C) 2006 Aleksey Cheusov
 
5
 *
 
6
 * This material is provided "as is", with absolutely no warranty expressed
 
7
 * or implied. Any use is at your own risk.
 
8
 *
 
9
 * Permission to use or copy this software for any purpose is hereby granted 
 
10
 * without fee. Permission to modify the code and to distribute modified
 
11
 * code is also granted without any restrictions.
 
12
 */
 
13
 
 
14
#ifndef HAVE_WCSDUP
 
15
 
 
16
#include "config.h"
 
17
 
 
18
#if defined(LIBC_SCCS) && !defined(lint) 
 
19
__RCSID("$NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $"); 
 
20
#endif /* LIBC_SCCS and not lint */ 
 
21
 
 
22
#include <stdlib.h>
 
23
#include <assert.h>
 
24
#include <wchar.h>
 
25
 
 
26
wchar_t *
 
27
wcsdup(const wchar_t *str)
 
28
{
 
29
        wchar_t *copy;
 
30
        size_t len;
 
31
 
 
32
        _DIAGASSERT(str != NULL);
 
33
 
 
34
        len = wcslen(str) + 1;
 
35
        copy = malloc(len * sizeof (wchar_t));
 
36
 
 
37
        if (!copy)
 
38
                return NULL;
 
39
 
 
40
        return wmemcpy(copy, str, len);
 
41
}
 
42
 
 
43
#endif