1 /* vi: set sw=4 ts=4: */
3 * xreadlink.c - safe implementation of readlink.
4 * Returns a NULL on failure...
10 * NOTE: This function returns a malloced char* that you will have to free
11 * yourself. You have been warned.
17 char *xreadlink(const char *path)
19 enum { GROWBY = 80 }; /* how large we will grow strings by */
22 int bufsize = 0, readsize = 0;
25 buf = xrealloc(buf, bufsize += GROWBY);
26 readsize = readlink(path, buf, bufsize); /* 1st try */
28 bb_perror_msg("%s", path);
33 while (bufsize < readsize + 1);