summaryrefslogtreecommitdiff
path: root/lib/libc/gen/basename.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/basename.c')
-rw-r--r--lib/libc/gen/basename.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c
index 9588c282bcf7..9552ab348666 100644
--- a/lib/libc/gen/basename.c
+++ b/lib/libc/gen/basename.c
@@ -40,12 +40,18 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
char *
-basename_r(path, bname)
+basename(path)
const char *path;
- char *bname;
{
+ static char *bname = NULL;
const char *endp, *startp;
+ if (bname == NULL) {
+ bname = (char *)malloc(MAXPATHLEN);
+ if (bname == NULL)
+ return(NULL);
+ }
+
/* Empty or NULL string gets treated as "." */
if (path == NULL || *path == '\0') {
(void)strcpy(bname, ".");
@@ -76,17 +82,3 @@ basename_r(path, bname)
bname[endp - startp + 1] = '\0';
return(bname);
}
-
-char *
-basename(path)
- const char *path;
-{
- static char *bname = NULL;
-
- if (bname == NULL) {
- bname = (char *)malloc(MAXPATHLEN);
- if (bname == NULL)
- return (NULL);
- }
- return (basename_r(path, bname));
-}