mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-23 03:55:42 -04:00
Introduce m_realpath() to replace realpath(path, NULL)
This commit is contained in:
parent
3724f943b9
commit
b9d8a5880a
22
src/misc.c
22
src/misc.c
@ -31,6 +31,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@ -101,6 +102,27 @@ safe_atol(const char *str, long *val)
|
|||||||
return 0;
|
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
|
uint32_t
|
||||||
djb_hash(void *data, size_t len)
|
djb_hash(void *data, size_t len)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,9 @@ safe_atoi(const char *str, int *val);
|
|||||||
int
|
int
|
||||||
safe_atol(const char *str, long *val);
|
safe_atol(const char *str, long *val);
|
||||||
|
|
||||||
|
char *
|
||||||
|
m_realpath(const char *pathname);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
djb_hash(void *data, size_t len);
|
djb_hash(void *data, size_t len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user