2011-06-25 17:26:44 +01: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 17:26:44 +01:00
|
|
|
#include <unistd.h>
|
2013-03-05 21:46:48 +01:00
|
|
|
|
2011-06-25 17:26:44 +01:00
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
void
|
2015-03-06 23:48:37 +00:00
|
|
|
apathmax(char **p, size_t *size)
|
2011-06-25 17:26:44 +01:00
|
|
|
{
|
|
|
|
errno = 0;
|
2014-11-19 20:59:37 +01:00
|
|
|
if ((*size = pathconf("/", _PC_PATH_MAX)) < 0) {
|
2014-11-13 19:54:28 +01:00
|
|
|
if (errno == 0) {
|
2015-03-06 23:48:37 +00:00
|
|
|
*size = PATH_MAX;
|
2013-03-05 21:46:48 +01:00
|
|
|
} else {
|
2011-06-25 17:26:44 +01:00
|
|
|
eprintf("pathconf:");
|
2013-03-05 21:46:48 +01:00
|
|
|
}
|
2015-03-06 23:48:37 +00:00
|
|
|
} else {
|
|
|
|
(*size)++;
|
2011-06-25 17:26:44 +01:00
|
|
|
}
|
2014-11-16 11:07:26 +01:00
|
|
|
*p = emalloc(*size);
|
2011-06-25 17:26:44 +01:00
|
|
|
}
|