diff options
author | Rob Landley <rob@landley.net> | 2005-09-11 23:45:28 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-09-11 23:45:28 +0000 |
commit | ba50217281e9265aa5935d184f698204143e765f (patch) | |
tree | 35a1e3986f566e87e18ec097a44ba9e165c15aa2 | |
parent | a7e14db495389371add9d2529adeaaf5566a5b36 (diff) | |
download | busybox-w32-ba50217281e9265aa5935d184f698204143e765f.tar.gz busybox-w32-ba50217281e9265aa5935d184f698204143e765f.tar.bz2 busybox-w32-ba50217281e9265aa5935d184f698204143e765f.zip |
Clean up memory allocation.
-rw-r--r-- | debianutils/readlink.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/debianutils/readlink.c b/debianutils/readlink.c index dd5612052..3042b83ec 100644 --- a/debianutils/readlink.c +++ b/debianutils/readlink.c | |||
@@ -4,20 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> | 5 | * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under GPL v2, see file LICENSE in this tarball for details. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | 8 | */ |
22 | 9 | ||
23 | #include <errno.h> | 10 | #include <errno.h> |
@@ -26,31 +13,20 @@ | |||
26 | #include <getopt.h> | 13 | #include <getopt.h> |
27 | #include "busybox.h" | 14 | #include "busybox.h" |
28 | 15 | ||
29 | #ifdef CONFIG_FEATURE_READLINK_FOLLOW | 16 | #define READLINK_FLAG_f (1 << 0) |
30 | # define READLINK_FOLLOW "f" | ||
31 | # define READLINK_FLAG_f (1 << 0) | ||
32 | #else | ||
33 | # define READLINK_FOLLOW "" | ||
34 | #endif | ||
35 | |||
36 | static const char readlink_options[] = READLINK_FOLLOW; | ||
37 | 17 | ||
38 | int readlink_main(int argc, char **argv) | 18 | int readlink_main(int argc, char **argv) |
39 | { | 19 | { |
40 | char *buf = NULL; | 20 | char *buf; |
41 | unsigned long opt = bb_getopt_ulflags(argc, argv, readlink_options); | 21 | unsigned long opt = bb_getopt_ulflags(argc, argv, |
42 | #ifdef CONFIG_FEATURE_READLINK_FOLLOW | 22 | ENABLE_FEATURE_READLINK_FOLLOW ? "f" : ""); |
43 | RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX); | ||
44 | #endif | ||
45 | 23 | ||
46 | if (optind + 1 != argc) | 24 | if (optind + 1 != argc) |
47 | bb_show_usage(); | 25 | bb_show_usage(); |
48 | 26 | ||
49 | #ifdef CONFIG_FEATURE_READLINK_FOLLOW | 27 | if (ENABLE_FEATURE_READLINK_FOLLOW && (opt & READLINK_FLAG_f)) |
50 | if (opt & READLINK_FLAG_f) { | 28 | buf = realpath(argv[optind], NULL); |
51 | buf = realpath(argv[optind], resolved_path); | 29 | else |
52 | } else | ||
53 | #endif | ||
54 | buf = xreadlink(argv[optind]); | 30 | buf = xreadlink(argv[optind]); |
55 | 31 | ||
56 | if (!buf) | 32 | if (!buf) |