2011-06-25 16:26:44 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <errno.h>
|
2015-03-06 23:48:37 +00:00
|
|
|
#include <limits.h>
|
2011-06-25 16:26:44 +00:00
|
|
|
#include <unistd.h>
|
2013-03-05 20:46:48 +00:00
|
|
|
|
2011-06-25 16:26:44 +00:00
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
void
|
2015-03-06 23:48:37 +00:00
|
|
|
apathmax(char **p, size_t *size)
|
2011-06-25 16:26:44 +00:00
|
|
|
{
|
|
|
|
errno = 0;
|
2014-11-19 19:59:37 +00:00
|
|
|
if ((*size = pathconf("/", _PC_PATH_MAX)) < 0) {
|
2014-11-13 18:54:28 +00:00
|
|
|
if (errno == 0) {
|
2015-03-06 23:48:37 +00:00
|
|
|
*size = PATH_MAX;
|
2013-03-05 20:46:48 +00:00
|
|
|
} else {
|
2011-06-25 16:26:44 +00:00
|
|
|
eprintf("pathconf:");
|
2013-03-05 20:46:48 +00:00
|
|
|
}
|
2015-03-06 23:48:37 +00:00
|
|
|
} else {
|
|
|
|
(*size)++;
|
2011-06-25 16:26:44 +00:00
|
|
|
}
|
2014-11-16 10:07:26 +00:00
|
|
|
*p = emalloc(*size);
|
2011-06-25 16:26:44 +00:00
|
|
|
}
|