* stdlib/canonicalize.c (__realpath): Remove unnecessary copy
	operations.
This commit is contained in:
Ulrich Drepper 2004-02-17 05:47:01 +00:00
parent f404736684
commit 33d5279258
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,8 @@
2004-02-16 Ulrich Drepper <drepper@redhat.com> 2004-02-16 Ulrich Drepper <drepper@redhat.com>
* stdlib/canonicalize.c (__realpath): Remove unnecessary copy
operations.
* nscd/nscd_conf.c (nscd_parse_file): Little optimization. * nscd/nscd_conf.c (nscd_parse_file): Little optimization.
2004-02-14 Thorsten Kukuk <kukuk@suse.de> 2004-02-14 Thorsten Kukuk <kukuk@suse.de>

View File

@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file. /* Return the canonical absolute name of a given file.
Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc. Copyright (C) 1996-2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */ 02111-1307 USA. */
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -204,12 +205,12 @@ __realpath (const char *name, char *resolved)
--dest; --dest;
*dest = '\0'; *dest = '\0';
return resolved ? memcpy (resolved, rpath, dest - rpath + 1) : rpath; assert (resolved == NULL || resolved == rpath);
return resolved ?: rpath;
error: error:
if (resolved) assert (resolved == NULL || resolved == rpath);
strcpy (resolved, rpath); if (resolved == NULL)
else
free (rpath); free (rpath);
return NULL; return NULL;
} }