aboutsummaryrefslogtreecommitdiff
path: root/libiberty/getcwd.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2000-02-22 15:59:20 +0000
committerIan Lance Taylor <ian@airs.com>2000-02-22 15:59:20 +0000
commite2eaf477991014a67bc122c3225f6a3fe6d1a8e6 (patch)
tree5937dcfd1baa6d55a635fde513e946dc33a05ca3 /libiberty/getcwd.c
parent252b5132c753830d5fd56823373aed85f2a0db63 (diff)
downloadgdb-e2eaf477991014a67bc122c3225f6a3fe6d1a8e6.zip
gdb-e2eaf477991014a67bc122c3225f6a3fe6d1a8e6.tar.gz
gdb-e2eaf477991014a67bc122c3225f6a3fe6d1a8e6.tar.bz2
import libiberty from egcs
Diffstat (limited to 'libiberty/getcwd.c')
-rw-r--r--libiberty/getcwd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c
index 06d55c0..47b1c1e 100644
--- a/libiberty/getcwd.c
+++ b/libiberty/getcwd.c
@@ -14,6 +14,9 @@ DESCRIPTION
current directory's path doesn't fit in LEN characters, the result
is NULL and errno is set.
+ If pathname is a null pointer, getcwd() will obtain size bytes of
+ space using malloc.
+
BUGS
Emulated via the getwd() call, which is reasonable for most
systems that do not have getcwd().
@@ -48,6 +51,13 @@ getcwd (buf, len)
errno = ERANGE;
return 0;
}
+ if (!buf) {
+ buf = (char*)malloc(len);
+ if (!buf) {
+ errno = ENOMEM;
+ return 0;
+ }
+ }
strcpy (buf, ourbuf);
}
return buf;