summaryrefslogtreecommitdiff
path: root/src/ln.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-09-28 08:14:34 +0000
committerJim Meyering <jim@meyering.net>2003-09-28 08:14:34 +0000
commit401673f8dde64618fdca63a0d3f8ed3c7bfe6d9c (patch)
treecfeb781ceca52eb77604604eb211c1d9db2f5003 /src/ln.c
parent156549eb5da827ad655151478084fb451688eaa7 (diff)
downloadcoreutils-401673f8dde64618fdca63a0d3f8ed3c7bfe6d9c.tar.xz
Minor efficiency tweak.
(PATH_BASENAME_CONCAT): Use memcpy rather than strcpy. (do_link): Likewise.
Diffstat (limited to 'src/ln.c')
-rw-r--r--src/ln.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ln.c b/src/ln.c
index 77055c70c..468a19af7 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -73,9 +73,10 @@ int symlink ();
{ \
const char *source_base; \
char *tmp_source; \
+ size_t buf_len = strlen (source) + 1; \
\
- tmp_source = (char *) alloca (strlen ((source)) + 1); \
- strcpy (tmp_source, (source)); \
+ tmp_source = (char *) alloca (buf_len); \
+ memcpy (tmp_source, (source), buf_len); \
strip_trailing_slashes (tmp_source); \
source_base = base_name (tmp_source); \
\
@@ -260,11 +261,13 @@ do_link (const char *source, const char *dest)
if (backup_type != none)
{
+ size_t buf_len;
char *tmp_backup = find_backup_file_name (dest, backup_type);
if (tmp_backup == NULL)
xalloc_die ();
- dest_backup = (char *) alloca (strlen (tmp_backup) + 1);
- strcpy (dest_backup, tmp_backup);
+ buf_len = strlen (tmp_backup) + 1;
+ dest_backup = (char *) alloca (buf_len);
+ memcpy (dest_backup, tmp_backup, buf_len);
free (tmp_backup);
if (rename (dest, dest_backup))
{