Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
88702c45
Commit
88702c45
authored
Apr 15, 2003
by
Roger Sayle
Committed by
Roger Sayle
Apr 15, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* strdup.c (strdup): Tweak implementation to use memcpy.
From-SVN: r65616
parent
f4e92987
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
libiberty/ChangeLog
+4
-0
libiberty/strdup.c
+16
-5
No files found.
libiberty/ChangeLog
View file @
88702c45
2003-04-14 Roger Sayle <roger@eyesopen.com>
* strdup.c (strdup): Tweak implementation to use memcpy.
2003-04-14 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.in (HAVE_UINTPTR_T): Always define.
...
...
libiberty/strdup.c
View file @
88702c45
...
...
@@ -9,13 +9,24 @@ Returns a pointer to a copy of @var{s} in memory obtained from
*/
#include <ansidecl.h>
#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
extern
size_t
strlen
PARAMS
((
const
char
*
));
extern
PTR
malloc
PARAMS
((
size_t
));
extern
PTR
memcpy
PARAMS
((
PTR
,
const
PTR
,
size_t
));
char
*
strdup
(
s
)
char
*
s
;
{
char
*
result
=
(
char
*
)
malloc
(
strlen
(
s
)
+
1
)
;
if
(
result
==
(
char
*
)
0
)
return
(
char
*
)
0
;
strcpy
(
result
,
s
)
;
return
result
;
size_t
len
=
strlen
(
s
)
+
1
;
char
*
result
=
(
char
*
)
malloc
(
len
);
if
(
result
==
(
char
*
)
0
)
return
(
char
*
)
0
;
return
(
char
*
)
memcpy
(
result
,
s
,
len
)
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment