aboutsummaryrefslogtreecommitdiff
path: root/gdb/nbsd-nat.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/nbsd-nat.c')
-rw-r--r--gdb/nbsd-nat.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index 72c471b..133de61 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -27,17 +27,17 @@
char *
nbsd_pid_to_exec_file (struct target_ops *self, int pid)
{
- size_t len = PATH_MAX;
- char *buf = xcalloc (len, sizeof (char));
- char *path;
+ ssize_t len;
+ static char buf[PATH_MAX];
+ char name[PATH_MAX];
- path = xstrprintf ("/proc/%d/exe", pid);
- if (readlink (path, buf, PATH_MAX - 1) == -1)
+ xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
+ len = readlink (name, buf, PATH_MAX - 1);
+ if (len != -1)
{
- xfree (buf);
- buf = NULL;
+ buf[len] = '\0';
+ return buf;
}
- xfree (path);
- return buf;
+ return NULL;
}