From 9f5b6fad89d6d4a451c7047f6565c57a27fdaa4f Mon Sep 17 00:00:00 2001 From: vda Date: Thu, 4 Jan 2007 17:59:59 +0000 Subject: new libbb func: xmalloc_realpath (+ use it where makes sense) syslogd, logread: add debugging code (disabled) syslogs: drastically smaller bss; fix "-C n" behaviour git-svn-id: svn://busybox.net/trunk/busybox@17156 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- libbb/xreadlink.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index 14863d9d5..76f52ca06 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c @@ -4,16 +4,13 @@ * Returns a NULL on failure... */ -#include +#include "libbb.h" /* * NOTE: This function returns a malloced char* that you will have to free * yourself. You have been warned. */ -#include -#include "libbb.h" - char *xreadlink(const char *path) { enum { GROWBY = 80 }; /* how large we will grow strings by */ @@ -36,3 +33,16 @@ char *xreadlink(const char *path) return buf; } + +char *xmalloc_realpath(const char *path) +{ +#ifdef __GLIBC__ + /* glibc provides a non-standard extension */ + return realpath(path, NULL); +#else + char buf[PATH_MAX+1]; + + /* on error returns NULL (xstrdup(NULL) ==NULL) */ + return xstrdup(realpath(path, buf)); +#endif +} -- cgit v1.2.3-55-g6feb