projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't write to inferior_ptid in fork-child.c
[deliverable/binutils-gdb.git]
/
libiberty
/
strndup.c
diff --git
a/libiberty/strndup.c
b/libiberty/strndup.c
index 3d6b93d3143574f2e680ccf53f207003e721a39f..a7ff3a9bbfc505d9da7ec7b50c119e4309fb6d25 100644
(file)
--- a/
libiberty/strndup.c
+++ b/
libiberty/strndup.c
@@
-1,5
+1,5
@@
/* Implement the strndup function.
/* Implement the strndup function.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005
-2020
Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
@@
-15,8
+15,8
@@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 5
9 Temple Place - Suite 330
,
-Boston, MA 0211
1-1307
, USA. */
+not, write to the Free Software Foundation, Inc., 5
1 Franklin Street - Fifth Floor
,
+Boston, MA 0211
0-1301
, USA. */
/*
/*
@@
-31,31
+31,22
@@
memory was available. The result is always NUL terminated.
*/
#include "ansidecl.h"
*/
#include "ansidecl.h"
-#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#include <stddef.h>
-#else
-#define size_t unsigned long
-#endif
-extern size_t str
len PARAMS ((const char*)
);
-extern PTR malloc
PARAMS ((size_t)
);
-extern PTR memcpy
PARAMS ((PTR, const PTR, size_t)
);
+extern size_t str
nlen (const char *s, size_t maxlen
);
+extern PTR malloc
(size_t
);
+extern PTR memcpy
(PTR, const PTR, size_t
);
char *
char *
-strndup(s, n)
- const char *s;
- size_t n;
+strndup (const char *s, size_t n)
{
char *result;
{
char *result;
- size_t len = str
len (s
);
+ size_t len = str
nlen (s, n
);
- if (n < len)
- len = n;
-
- result = malloc (len + 1);
+ result = (char *) malloc (len + 1);
if (!result)
return 0;
result[len] = '\0';
if (!result)
return 0;
result[len] = '\0';
- return memcpy (result, s, len);
+ return
(char *)
memcpy (result, s, len);
}
}
This page took
0.034836 seconds
and
4
git commands to generate.