diff options
author | Jim Meyering <jim@meyering.net> | 2003-09-28 08:14:34 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-09-28 08:14:34 +0000 |
commit | 401673f8dde64618fdca63a0d3f8ed3c7bfe6d9c (patch) | |
tree | cfeb781ceca52eb77604604eb211c1d9db2f5003 | |
parent | 156549eb5da827ad655151478084fb451688eaa7 (diff) | |
download | coreutils-401673f8dde64618fdca63a0d3f8ed3c7bfe6d9c.tar.xz |
Minor efficiency tweak.
(PATH_BASENAME_CONCAT): Use memcpy rather than strcpy.
(do_link): Likewise.
-rw-r--r-- | src/ln.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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)) { |