From ce4f7a33eb6bb539db2ad856e2c19a4cdf6ca3ee Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 7 Jun 2020 23:34:47 +0200 Subject: tools: Avoid copying optarg where possible --- tools/ideviceimagemounter.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'tools/ideviceimagemounter.c') 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"); -- cgit v1.1-32-gdbae