You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
16 years ago
|
/***************************************************************************
|
||
|
* _ _ ____ _
|
||
|
* Project ___| | | | _ \| |
|
||
|
* / __| | | | |_) | |
|
||
|
* | (__| |_| | _ <| |___
|
||
|
* \___|\___/|_| \_\_____|
|
||
|
*
|
||
10 years ago
|
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||
16 years ago
|
*
|
||
|
* This software is licensed as described in the file COPYING, which
|
||
|
* you should have received as part of this distribution. The terms
|
||
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||
|
*
|
||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||
|
* copies of the Software, and permit persons to whom the Software is
|
||
|
* furnished to do so, under the terms of the COPYING file.
|
||
|
*
|
||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||
|
* KIND, either express or implied.
|
||
|
*
|
||
|
***************************************************************************/
|
||
10 years ago
|
/*
|
||
|
* This file is 'mem-include-scan' clean. See test 1132.
|
||
|
*/
|
||
|
#include "curl_setup.h"
|
||
16 years ago
|
|
||
|
#include "strdup.h"
|
||
|
|
||
|
#ifndef HAVE_STRDUP
|
||
|
char *curlx_strdup(const char *str)
|
||
|
{
|
||
10 years ago
|
size_t len;
|
||
16 years ago
|
char *newstr;
|
||
|
|
||
10 years ago
|
if(!str)
|
||
16 years ago
|
return (char *)NULL;
|
||
|
|
||
|
len = strlen(str);
|
||
10 years ago
|
|
||
|
if(len >= ((size_t)-1) / sizeof(char))
|
||
|
return (char *)NULL;
|
||
|
|
||
|
newstr = malloc((len+1)*sizeof(char));
|
||
|
if(!newstr)
|
||
16 years ago
|
return (char *)NULL;
|
||
|
|
||
10 years ago
|
memcpy(newstr,str,(len+1)*sizeof(char));
|
||
16 years ago
|
|
||
|
return newstr;
|
||
|
|
||
|
}
|
||
|
#endif
|