projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git]
/
libiberty
/
strndup.c
diff --git
a/libiberty/strndup.c
b/libiberty/strndup.c
index 9e9b4e2991f833082acd176f48825f76d5a888b9..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.
@@
-33,7
+33,7
@@
memory was available. The result is always NUL terminated.
#include "ansidecl.h"
#include <stddef.h>
#include "ansidecl.h"
#include <stddef.h>
-extern size_t str
len (const char*
);
+extern size_t str
nlen (const char *s, size_t maxlen
);
extern PTR malloc (size_t);
extern PTR memcpy (PTR, const PTR, size_t);
extern PTR malloc (size_t);
extern PTR memcpy (PTR, const PTR, size_t);
@@
-41,10
+41,7
@@
char *
strndup (const char *s, size_t n)
{
char *result;
strndup (const char *s, size_t n)
{
char *result;
- size_t len = strlen (s);
-
- if (n < len)
- len = n;
+ size_t len = strnlen (s, n);
result = (char *) malloc (len + 1);
if (!result)
result = (char *) malloc (len + 1);
if (!result)
This page took
0.024774 seconds
and
4
git commands to generate.