new libbb func: xmalloc_realpath (+ use it where makes sense)
syslogd, logread: add debugging code (disabled) syslogs: drastically smaller bss; fix "-C n" behaviour
This commit is contained in:
@@ -4,16 +4,13 @@
|
||||
* Returns a NULL on failure...
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "libbb.h"
|
||||
|
||||
/*
|
||||
* NOTE: This function returns a malloced char* that you will have to free
|
||||
* yourself. You have been warned.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#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
|
||||
}
|
||||
|
Reference in New Issue
Block a user