summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-05-12 10:00:52 +0000
committerJim Meyering <jim@meyering.net>2001-05-12 10:00:52 +0000
commit98e643ab3b37aa69e70afa17c90a0269735a71a6 (patch)
treed851af2dab8179baaec1ecaaa4418d708b5773cf
parentb2604c5d125b2489ee8ff677992af95e25fa6ecf (diff)
downloadcoreutils-98e643ab3b37aa69e70afa17c90a0269735a71a6.tar.xz
(strip_trailing_slashes): Remove; now in dirname.h.
(make_path_private): Use dir_len instead of dir_name, and avoid an extra mealloc call.
-rw-r--r--src/cp.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/cp.c b/src/cp.c
index d98dfd72e..9511c376f 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -77,8 +77,6 @@ enum
UNLINK_DEST_BEFORE_OPENING
};
-void strip_trailing_slashes ();
-
/* Initial number of entries in each hash table entry's table of inodes. */
#define INITIAL_HASH_MODULE 100
@@ -342,18 +340,18 @@ make_path_private (const char *const_dirpath, int src_offset, int mode,
struct stat stats;
char *dirpath; /* A copy of CONST_DIRPATH we can change. */
char *src; /* Source name in `dirpath'. */
- char *tmp_dst_dirname; /* Leading path of `dirpath', malloc. */
- char *dst_dirname; /* Leading path of `dirpath', alloca. */
+ char *dst_dirname; /* Leading path of `dirpath'. */
+ size_t dirlen; /* Length of leading path of `dirpath'. */
dirpath = (char *) alloca (strlen (const_dirpath) + 1);
strcpy (dirpath, const_dirpath);
src = dirpath + src_offset;
- tmp_dst_dirname = dir_name (dirpath);
- dst_dirname = (char *) alloca (strlen (tmp_dst_dirname) + 1);
- strcpy (dst_dirname, tmp_dst_dirname);
- free (tmp_dst_dirname);
+ dirlen = dir_len (dirpath);
+ dst_dirname = (char *) alloca (dirlen + 1);
+ memcpy (dst_dirname, dirpath, dirlen);
+ dst_dirname[dirlen] = '\0';
*attr_list = NULL;