2 * xreadlink.c - safe implementation of readlink.
3 * Returns a NULL on failure...
9 * NOTE: This function returns a malloced char* that you will have to free
10 * yourself. You have been warned.
16 extern char *xreadlink(const char *path
)
18 static const int GROWBY
= 80; /* how large we will grow strings by */
21 int bufsize
= 0, readsize
= 0;
24 buf
= xrealloc(buf
, bufsize
+= GROWBY
);
25 readsize
= readlink(path
, buf
, bufsize
); /* 1st try */
27 perror_msg("%s", path
);
32 while (bufsize
< readsize
+ 1);