diff options
| author | 2020-06-07 23:34:47 +0200 | |
|---|---|---|
| committer | 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 @@ | |||
| 51 | static int list_mode = 0; | 51 | static int list_mode = 0; |
| 52 | static int use_network = 0; | 52 | static int use_network = 0; |
| 53 | static int xml_mode = 0; | 53 | static int xml_mode = 0; |
| 54 | static char *udid = NULL; | 54 | static const char *udid = NULL; |
| 55 | static char *imagetype = NULL; | 55 | static const char *imagetype = NULL; |
| 56 | 56 | ||
| 57 | static const char PKG_PATH[] = "PublicStaging"; | 57 | static const char PKG_PATH[] = "PublicStaging"; |
| 58 | static const char PATH_PREFIX[] = "/private/var/mobile/Media"; | 58 | static const char PATH_PREFIX[] = "/private/var/mobile/Media"; |
| @@ -116,8 +116,7 @@ static void parse_opts(int argc, char **argv) | |||
| 116 | print_usage(argc, argv); | 116 | print_usage(argc, argv); |
| 117 | exit(2); | 117 | exit(2); |
| 118 | } | 118 | } |
| 119 | free(udid); | 119 | udid = optarg; |
| 120 | udid = strdup(optarg); | ||
| 121 | break; | 120 | break; |
| 122 | case 'n': | 121 | case 'n': |
| 123 | use_network = 1; | 122 | use_network = 1; |
| @@ -126,9 +125,7 @@ static void parse_opts(int argc, char **argv) | |||
| 126 | list_mode = 1; | 125 | list_mode = 1; |
| 127 | break; | 126 | break; |
| 128 | case 't': | 127 | case 't': |
| 129 | if (imagetype) | 128 | imagetype = optarg; |
| 130 | free(imagetype); | ||
| 131 | imagetype = strdup(optarg); | ||
| 132 | break; | 129 | break; |
| 133 | case 'x': | 130 | case 'x': |
| 134 | xml_mode = 1; | 131 | xml_mode = 1; |
| @@ -281,10 +278,9 @@ int main(int argc, char **argv) | |||
| 281 | if (list_mode) { | 278 | if (list_mode) { |
| 282 | /* list mounts mode */ | 279 | /* list mounts mode */ |
| 283 | if (!imagetype) { | 280 | if (!imagetype) { |
| 284 | imagetype = strdup("Developer"); | 281 | imagetype = "Developer"; |
| 285 | } | 282 | } |
| 286 | err = mobile_image_mounter_lookup_image(mim, imagetype, &result); | 283 | err = mobile_image_mounter_lookup_image(mim, imagetype, &result); |
| 287 | free(imagetype); | ||
| 288 | if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { | 284 | if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { |
| 289 | res = 0; | 285 | res = 0; |
| 290 | if (xml_mode) { | 286 | if (xml_mode) { |
| @@ -329,7 +325,7 @@ int main(int argc, char **argv) | |||
| 329 | 325 | ||
| 330 | 326 | ||
| 331 | if (!imagetype) { | 327 | if (!imagetype) { |
| 332 | imagetype = strdup("Developer"); | 328 | imagetype = "Developer"; |
| 333 | } | 329 | } |
| 334 | 330 | ||
| 335 | switch(disk_image_upload_type) { | 331 | switch(disk_image_upload_type) { |
| @@ -407,7 +403,6 @@ int main(int argc, char **argv) | |||
| 407 | 403 | ||
| 408 | printf("Mounting...\n"); | 404 | printf("Mounting...\n"); |
| 409 | err = mobile_image_mounter_mount_image(mim, mountname, sig, sig_length, imagetype, &result); | 405 | err = mobile_image_mounter_mount_image(mim, mountname, sig, sig_length, imagetype, &result); |
| 410 | free(imagetype); | ||
| 411 | if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { | 406 | if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { |
| 412 | if (result) { | 407 | if (result) { |
| 413 | plist_t node = plist_dict_get_item(result, "Status"); | 408 | plist_t node = plist_dict_get_item(result, "Status"); |
