diff options
author | Nikias Bassen | 2020-06-07 23:34:47 +0200 |
---|---|---|
committer | Nikias Bassen | 2020-06-07 23:34:47 +0200 |
commit | ce4f7a33eb6bb539db2ad856e2c19a4cdf6ca3ee (patch) | |
tree | 19d06556794cdfdc31e5539c35f6a42abf457939 /tools/ideviceimagemounter.c | |
parent | fb99e7c9d22c7d07b3b5fdb5064d3aa6cef88e62 (diff) | |
download | libimobiledevice-ce4f7a33eb6bb539db2ad856e2c19a4cdf6ca3ee.tar.gz libimobiledevice-ce4f7a33eb6bb539db2ad856e2c19a4cdf6ca3ee.tar.bz2 |
tools: Avoid copying optarg where possible
Diffstat (limited to 'tools/ideviceimagemounter.c')
-rw-r--r-- | tools/ideviceimagemounter.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index c89ddd3..325a9e2 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c @@ -51,8 +51,8 @@ static int list_mode = 0; static int use_network = 0; static int xml_mode = 0; -static char *udid = NULL; -static char *imagetype = NULL; +static const char *udid = NULL; +static const char *imagetype = NULL; static const char PKG_PATH[] = "PublicStaging"; static const char PATH_PREFIX[] = "/private/var/mobile/Media"; @@ -116,8 +116,7 @@ static void parse_opts(int argc, char **argv) print_usage(argc, argv); exit(2); } - free(udid); - udid = strdup(optarg); + udid = optarg; break; case 'n': use_network = 1; @@ -126,9 +125,7 @@ static void parse_opts(int argc, char **argv) list_mode = 1; break; case 't': - if (imagetype) - free(imagetype); - imagetype = strdup(optarg); + imagetype = optarg; break; case 'x': xml_mode = 1; @@ -281,10 +278,9 @@ int main(int argc, char **argv) if (list_mode) { /* list mounts mode */ if (!imagetype) { - imagetype = strdup("Developer"); + imagetype = "Developer"; } err = mobile_image_mounter_lookup_image(mim, imagetype, &result); - free(imagetype); if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { res = 0; if (xml_mode) { @@ -329,7 +325,7 @@ int main(int argc, char **argv) if (!imagetype) { - imagetype = strdup("Developer"); + imagetype = "Developer"; } switch(disk_image_upload_type) { @@ -407,7 +403,6 @@ int main(int argc, char **argv) printf("Mounting...\n"); err = mobile_image_mounter_mount_image(mim, mountname, sig, sig_length, imagetype, &result); - free(imagetype); if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { if (result) { plist_t node = plist_dict_get_item(result, "Status"); |