aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-04-30 18:17:00 +0000
committerMark Whitley <markw@lineo.com>2001-04-30 18:17:00 +0000
commit8a633268ef478a31bd649d582ce07e9c26a4a03a (patch)
treea90a2bc3c3815f7f0e70f009b9b175736902a848 /miscutils
parent6f343944548c2e41fde4a376e805bf322a8e01c9 (diff)
downloadbusybox-8a633268ef478a31bd649d582ce07e9c26a4a03a.tar.gz
Made new xreadlink function for libbb and changed applets to use it instead of
readlink(2).
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/readlink.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/miscutils/readlink.c b/miscutils/readlink.c
index 74196e11d..226649544 100644
--- a/miscutils/readlink.c
+++ b/miscutils/readlink.c
@@ -30,21 +30,17 @@
int readlink_main(int argc, char **argv)
{
char *buf = NULL;
- int bufsize = 128, size = 128;
+
+ /* no options, no getopt */
if (argc != 2)
show_usage();
- while (bufsize < size + 1) {
- bufsize *= 2;
- buf = xrealloc(buf, bufsize);
- size = readlink(argv[1], buf, bufsize);
- if (size == -1)
- perror_msg_and_die("%s", argv[1]);
- }
-
- buf[size] = '\0';
+ buf = xreadlink(argv[1]);
puts(buf);
+#ifdef BB_FEATURE_CLEAN_UP
+ free(buf);
+#endif
return EXIT_SUCCESS;
}