Introduce m_realpath() to replace realpath(path, NULL)

This commit is contained in:
Julien BLACHE 2010-01-09 13:43:29 +01:00
parent 3724f943b9
commit b9d8a5880a
2 changed files with 25 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/param.h>
#include "logger.h"
#include "misc.h"
@ -101,6 +102,27 @@ safe_atol(const char *str, long *val)
return 0;
}
char *
m_realpath(const char *pathname)
{
char buf[PATH_MAX];
char *ret;
ret = realpath(pathname, buf);
if (!ret)
return NULL;
ret = strdup(buf);
if (!ret)
{
DPRINTF(E_LOG, L_MISC, "Out of memory for realpath\n");
return NULL;
}
return ret;
}
uint32_t
djb_hash(void *data, size_t len)
{

View File

@ -10,6 +10,9 @@ safe_atoi(const char *str, int *val);
int
safe_atol(const char *str, long *val);
char *
m_realpath(const char *pathname);
uint32_t
djb_hash(void *data, size_t len);