Changeset 900 in MondoRescue for trunk/mondo/src/mondorestore/mondo-rstr-newt.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r783 r900 16 16 17 17 #include "mondo-rstr-newt.h" 18 #include "mr_mem.h" 18 19 19 20 /** … … 78 79 (_ 79 80 (" Add one of the following unallocated RAID partitions to this RAID device.")); 80 asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));81 mr_asprintf(&tmp, "%-26s %s", _("Device"), _("Size")); 81 82 headerMsg = newtLabel(1, 1, tmp); 82 paranoid_free(tmp);83 mr_free(tmp); 83 84 84 85 partitionsListbox = … … 167 168 assert(keylist != NULL); 168 169 169 asprintf(&device_str, "/dev/");170 asprintf(&mountpoint_str, "/");170 mr_asprintf(&device_str, "/dev/"); 171 mr_asprintf(&mountpoint_str, "/"); 171 172 #ifdef __FreeBSD__ 172 asprintf(&format_str, "ufs");173 mr_asprintf(&format_str, "ufs"); 173 174 #else 174 asprintf(&format_str, "ext2");175 mr_asprintf(&format_str, "ext2"); 175 176 #endif 176 177 newtOpenWindow(20, 5, 48, 10, _("Add entry")); … … 199 200 b_res = newtRunForm(myForm); 200 201 201 paranoid_free(device_str);202 asprintf(&device_str, device_here);202 mr_free(device_str); 203 mr_asprintf(&device_str, device_here); 203 204 strip_spaces(device_str); 204 205 205 paranoid_free(format_str);206 asprintf(&format_str, format_here);206 mr_free(format_str); 207 mr_asprintf(&format_str, format_here); 207 208 strip_spaces(format_str); 208 209 209 paranoid_free(mountpoint_str);210 asprintf(&mountpoint_str, mountpoint_here);210 mr_free(mountpoint_str); 211 mr_asprintf(&mountpoint_str, mountpoint_here); 211 212 strip_spaces(mountpoint_str); 212 213 213 paranoid_free(size_str);214 asprintf(&size_str, size_here);214 mr_free(size_str); 215 mr_asprintf(&size_str, size_here); 215 216 strip_spaces(size_str); 216 217 … … 234 235 return; 235 236 } 236 asprintf(&drive_to_add, device_str);237 mr_asprintf(&drive_to_add, device_str); 237 238 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 238 239 num_to_add = atoi(drive_to_add + i); 239 240 drive_to_add[i] = '\0'; 240 paranoid_free(drive_to_add);241 mr_free(drive_to_add); 241 242 242 243 currline = mountlist->entries; 243 244 strcpy(mountlist->el[currline].device, device_str); 244 245 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 245 paranoid_free(mountpoint_str);246 mr_free(mountpoint_str); 246 247 247 248 strcpy(mountlist->el[currline].format, format_str); 248 paranoid_free(format_str);249 mr_free(format_str); 249 250 250 251 mountlist->el[currline].size = atol(size_str) * 1024; 251 paranoid_free(size_str);252 mr_free(size_str); 252 253 253 254 mountlist->entries++; … … 256 257 device_str); 257 258 } 258 paranoid_free(device_str);259 mr_free(device_str); 259 260 redraw_mountlist(mountlist, keylist, listbox); 260 261 } … … 296 297 } 297 298 } 298 paranoid_free(sz_out);299 mr_free(sz_out); 299 300 } 300 301 #endif … … 335 336 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 336 337 if (i == raidlist->entries) { 337 asprintf(&tmp,338 mr_asprintf(&tmp, 338 339 "Cannot calc size of raid device %s - cannot find it in raidlist", 339 340 raid_device); 340 341 log_it(tmp); 341 paranoid_free(tmp);342 mr_free(tmp); 342 343 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 343 344 // then it has no size, right? … … 351 352 int k = 0, l = 0; 352 353 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 353 asprintf(&devname, raidrec->plex[j].sd[k].which_device);354 mr_asprintf(&devname, raidrec->plex[j].sd[k].which_device); 354 355 for (l = 0; l < raidlist->disks.entries; ++l) { 355 356 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 379 380 } 380 381 } 381 paranoid_free(devname);382 mr_free(devname); 382 383 } 383 384 … … 400 401 } 401 402 402 asprintf(&tmp, "I have calculated %s's real size to be %ld",403 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 403 404 raid_device, (long) smallest_plex); 404 405 log_it(tmp); 405 paranoid_free(tmp);406 mr_free(tmp); 406 407 return (smallest_plex); 407 408 #else … … 431 432 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 432 433 if (i == raidlist->entries) { 433 asprintf(&tmp,434 mr_asprintf(&tmp, 434 435 "Cannot calc size of raid device %s - cannot find it in raidlist", 435 436 raid_device); 436 437 log_it(tmp); 437 paranoid_free(tmp);438 mr_free(tmp); 438 439 return (999999999); 439 440 } … … 458 459 total_size = smallest_partition * (noof_partitions - 1); 459 460 } 460 asprintf(&tmp, "I have calculated %s's real size to be %ld",461 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 461 462 raid_device, (long) total_size); 462 463 log_it(tmp); 463 paranoid_free(tmp);464 mr_free(tmp); 464 465 return (total_size); 465 466 #endif … … 487 488 char *sz = NULL; 488 489 489 asprintf(&prompt,490 mr_asprintf(&prompt, 490 491 _ 491 492 ("Please enter the RAID level you want. (concat, striped, raid5)")); 492 493 if (raidrec->raidlevel == -1) { 493 asprintf(&tmp, "concat");494 mr_asprintf(&tmp, "concat"); 494 495 } else if (raidrec->raidlevel == 0) { 495 asprintf(&tmp, "striped");496 mr_asprintf(&tmp, "striped"); 496 497 } else { 497 asprintf(&tmp, "raid%i", raidrec->raidlevel);498 mr_asprintf(&tmp, "raid%i", raidrec->raidlevel); 498 499 } 499 500 for (out = 999; out == 999;) { … … 504 505 /* BERLIOS: Useless ??? 505 506 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 506 asprintf(&sz, tmp);507 mr_asprintf(&sz, tmp); 507 508 strncpy(tmp, sz + 1, strlen(sz) - 2); 508 509 tmp[strlen(sz) - 2] = '\0'; 509 paranoid_free(sz);510 mr_free(sz); 510 511 } 511 512 */ … … 518 519 } 519 520 log_it(tmp); 520 paranoid_free(tmp);521 mr_free(tmp); 521 522 if (is_this_raid_personality_registered(out)) { 522 523 log_it … … 530 531 } 531 532 } 532 paranoid_free(prompt);533 mr_free(prompt); 533 534 raidrec->raidlevel = out; 534 535 #else … … 544 545 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 545 546 personalities = last_line_of_file("/tmp/raid-personalities.txt"); 546 asprintf(&prompt, _("Please enter the RAID level you want. %s"),547 mr_asprintf(&prompt, _("Please enter the RAID level you want. %s"), 547 548 personalities); 548 paranoid_free(personalities);549 mr_free(personalities); 549 550 550 551 if (raidrec->raid_level == -1) { 551 asprintf(&tmp, "linear");552 mr_asprintf(&tmp, "linear"); 552 553 } else { 553 asprintf(&tmp, "%d", raidrec->raid_level);554 mr_asprintf(&tmp, "%d", raidrec->raid_level); 554 555 } 555 556 for (out = 999; … … 563 564 /* BERLIOS: Useless ??? 564 565 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 565 asprintf(&sz, tmp);566 paranoid_free(tmp);567 568 asprintf(&tmp, sz + 1);566 mr_asprintf(&sz, tmp); 567 mr_free(tmp); 568 569 mr_asprintf(&tmp, sz + 1); 569 570 tmp[strlen(sz) - 2] = '\0'; 570 paranoid_free(sz);571 mr_free(sz); 571 572 } 572 573 */ … … 591 592 } 592 593 } 593 paranoid_free(tmp);594 paranoid_free(prompt);594 mr_free(tmp); 595 mr_free(prompt); 595 596 raidrec->raid_level = out; 596 597 #endif … … 659 660 assert_string_is_neither_NULL_nor_zerolength(raid_device); 660 661 661 asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),662 mr_asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"), 662 663 disklist->el[currline].device, raid_device); 663 664 if (!ask_me_yes_or_no(tmp)) { 664 paranoid_free(tmp);665 mr_free(tmp); 665 666 return; 666 667 } 667 paranoid_free(tmp);668 mr_free(tmp); 668 669 for (pos = currline; pos < disklist->entries - 1; pos++) { 669 670 /* memcpy((void*)&disklist->el[pos], (void*)&disklist->el[pos+1], sizeof(struct s_disk)); */ … … 707 708 device); 708 709 if (pos >= 0) { 709 asprintf(&tmp,710 mr_asprintf(&tmp, 710 711 _("Cannot delete %s: it is in use by RAID device %s"), 711 712 mountlist->el[currline].device, 712 713 raidlist->el[pos].OSSWAP(raid_device, volname)); 713 714 popup_and_OK(tmp); 714 paranoid_free(tmp);715 mr_free(tmp); 715 716 return; 716 717 } 717 asprintf(&tmp, _("Delete %s - are you sure?"),718 mr_asprintf(&tmp, _("Delete %s - are you sure?"), 718 719 mountlist->el[currline].device); 719 720 if (!ask_me_yes_or_no(tmp)) { 720 paranoid_free(tmp);721 mr_free(tmp); 721 722 return; 722 723 } 723 paranoid_free(tmp);724 mr_free(tmp); 724 725 725 726 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 726 asprintf(&device, mountlist->el[currline].device);727 mr_asprintf(&device, mountlist->el[currline].device); 727 728 delete_raidlist_entry(mountlist, raidlist, device); 728 729 for (currline = 0; … … 732 733 if (currline == mountlist->entries) { 733 734 log_it("Dev is gone. I can't delete it. Ho-hum"); 734 paranoid_free(device);735 mr_free(device); 735 736 return; 736 737 } 737 paranoid_free(device);738 mr_free(device); 738 739 } 739 740 memcpy((void *) &mountlist->el[currline], … … 775 776 return; 776 777 } 777 asprintf(&tmp,778 mr_asprintf(&tmp, 778 779 _("Do you want me to delete %s's partitions, too?"), device); 779 780 delete_partitions_too = ask_me_yes_or_no(tmp); … … 820 821 items--; 821 822 } 822 paranoid_free(tmp);823 mr_free(tmp); 823 824 824 825 raidlist->entries = items; … … 845 846 846 847 av = &raidrec->additional_vars; 847 asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);848 mr_asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label); 848 849 if (ask_me_yes_or_no(tmp)) { 849 850 if (!strcmp(av->el[lino].label, "persistent-superblock") 850 851 || !strcmp(av->el[lino].label, "chunk-size")) { 851 paranoid_free(tmp);852 asprintf(&tmp, _("%s must not be deleted. It would be bad."),852 mr_free(tmp); 853 mr_asprintf(&tmp, _("%s must not be deleted. It would be bad."), 853 854 av->el[lino].label); 854 855 popup_and_OK(tmp); 855 856 } else { 856 paranoid_free(av->el[lino].label);857 paranoid_free(av->el[lino].value);857 mr_free(av->el[lino].label); 858 mr_free(av->el[lino].value); 858 859 memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--], 859 860 sizeof(struct raid_var_line)); … … 864 865 } 865 866 } 866 paranoid_free(tmp);867 mr_free(tmp); 867 868 } 868 869 #endif … … 924 925 if (!warned_already) { 925 926 warned_already = TRUE; 926 asprintf(&tmp,927 mr_asprintf(&tmp, 927 928 _ 928 929 ("Too many lines. Displaying first %d entries only. Close a directory to see more."), 929 930 ARBITRARY_MAXIMUM); 930 931 popup_and_OK(tmp); 931 paranoid_free(tmp);932 mr_free(tmp); 932 933 } 933 934 } else { … … 948 949 (g_strings_of_flist_window[i], 949 950 g_strings_of_flist_window[i - 1]) < 0) { 950 asprintf(&tmp, g_strings_of_flist_window[i]);951 mr_asprintf(&tmp, g_strings_of_flist_window[i]); 951 952 strcpy(g_strings_of_flist_window[i], 952 953 g_strings_of_flist_window[i - 1]); 953 954 strcpy(g_strings_of_flist_window[i - 1], tmp); 954 paranoid_free(tmp);955 mr_free(tmp); 955 956 956 957 dummybool = g_is_path_selected[i]; … … 963 964 newtListboxClear(listbox); 964 965 for (i = 0; i < lines_in_flist_window; i++) { 965 asprintf(&tmp, "%c%c %-80s",966 mr_asprintf(&tmp, "%c%c %-80s", 966 967 (g_is_path_selected[i] ? '*' : ' '), 967 968 (g_is_path_expanded[i] ? '+' : '-'), … … 973 974 keylist[i] = (void *) i; 974 975 newtListboxAppendEntry(listbox, tmp, keylist[i]); 975 paranoid_free(tmp);976 mr_free(tmp); 976 977 } 977 978 return (lines_in_flist_window); … … 1223 1224 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1224 1225 sizeof(struct raidlist_itself)); 1225 asprintf(&device_str, mountlist->el[currline].device);1226 asprintf(&device_used_to_be, mountlist->el[currline].device);1227 asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);1228 asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);1229 asprintf(&format_str, mountlist->el[currline].format);1230 asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);1226 mr_asprintf(&device_str, mountlist->el[currline].device); 1227 mr_asprintf(&device_used_to_be, mountlist->el[currline].device); 1228 mr_asprintf(&mountpoint_str, mountlist->el[currline].mountpoint); 1229 mr_asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint); 1230 mr_asprintf(&format_str, mountlist->el[currline].format); 1231 mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1231 1232 1232 1233 newtOpenWindow(20, 5, 48, 10, "Edit entry"); … … 1237 1238 deviceComp = 1238 1239 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1239 paranoid_free(device_str);1240 mr_free(device_str); 1240 1241 1241 1242 mountpointComp = 1242 1243 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1243 paranoid_free(mountpoint_str);1244 mr_free(mountpoint_str); 1244 1245 1245 1246 formatComp = 1246 1247 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1247 paranoid_free(format_str);1248 mr_free(format_str); 1248 1249 1249 1250 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) … … 1253 1254 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 1254 1255 } 1255 paranoid_free(size_str);1256 mr_free(size_str); 1256 1257 1257 1258 bOK = newtButton(2, 6, _(" OK ")); … … 1270 1271 b_res = newtRunForm(myForm); 1271 1272 1272 paranoid_free(device_str);1273 asprintf(&device_str, device_here);1273 mr_free(device_str); 1274 mr_asprintf(&device_str, device_here); 1274 1275 strip_spaces(device_str); 1275 1276 1276 paranoid_free(mountpoint_str);1277 asprintf(&mountpoint_str, mountpoint_here);1277 mr_free(mountpoint_str); 1278 mr_asprintf(&mountpoint_str, mountpoint_here); 1278 1279 strip_spaces(mountpoint_str); 1279 1280 1280 paranoid_free(format_str);1281 asprintf(&format_str, format_here);1282 paranoid_free(format_here);1281 mr_free(format_str); 1282 mr_asprintf(&format_str, format_here); 1283 mr_free(format_here); 1283 1284 strip_spaces(format_str); 1284 1285 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) … … 1295 1296 continue; 1296 1297 } 1297 paranoid_free(mountpt_used_to_be);1298 mr_free(mountpt_used_to_be); 1298 1299 1299 1300 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1300 1301 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1301 asprintf(&size_str, size_here);1302 mr_asprintf(&size_str, size_here); 1302 1303 strip_spaces(size_str); 1303 1304 } else { 1304 asprintf(&size_str, "%ld",1305 mr_asprintf(&size_str, "%ld", 1305 1306 calculate_raid_device_size(mountlist, raidlist, 1306 1307 mountlist->el[currline]. … … 1308 1309 newtLabelSetText(sizeComp, size_str); 1309 1310 } 1310 paranoid_free(size_here);1311 mr_free(size_here); 1311 1312 1312 1313 /* do not let user click RAID button if user has changed device_str */ … … 1325 1326 device); 1326 1327 if (j < 0) { 1327 asprintf(&tmp,1328 mr_asprintf(&tmp, 1328 1329 _ 1329 1330 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1330 1331 mountlist->el[currline].device); 1331 1332 popup_and_OK(tmp); 1332 paranoid_free(tmp);1333 mr_free(tmp); 1333 1334 } else { 1334 1335 log_it(_("edit_raidlist_entry - calling")); … … 1339 1340 } 1340 1341 } 1341 paranoid_free(device_here);1342 paranoid_free(mountpoint_here);1342 mr_free(device_here); 1343 mr_free(mountpoint_here); 1343 1344 1344 1345 newtFormDestroy(myForm); … … 1352 1353 strcpy(mountlist->el[currline].device, device_str); 1353 1354 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1354 paranoid_free(mountpoint_str);1355 mr_free(mountpoint_str); 1355 1356 1356 1357 strcpy(mountlist->el[currline].format, format_str); 1357 paranoid_free(format_str);1358 mr_free(format_str); 1358 1359 1359 1360 if (strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1366 1367 } 1367 1368 } 1368 paranoid_free(size_str);1369 mr_free(size_str); 1369 1370 1370 1371 newtListboxSetEntry(listbox, (long) keylist[currline], … … 1397 1398 #endif 1398 1399 redraw_mountlist(mountlist, keylist, listbox); 1399 paranoid_free(device_str);1400 paranoid_free(device_used_to_be);1400 mr_free(device_str); 1401 mr_free(device_used_to_be); 1401 1402 } 1402 1403 … … 1516 1517 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1517 1518 sizeof(struct vinum_volume)); 1518 asprintf(&title_of_editraidForm_window, _("Plexes on %s"),1519 mr_asprintf(&title_of_editraidForm_window, _("Plexes on %s"), 1519 1520 raidrec->volname); 1520 1521 newtPushHelpLine(_(" Please select a plex to edit")); 1521 1522 newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window); 1522 paranoid_free(title_of_editraidForm_window);1523 mr_free(title_of_editraidForm_window); 1523 1524 1524 1525 for (;;) { 1525 asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));1526 mr_asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1526 1527 1527 1528 bOK = newtCompactButton(2, 13, _(" OK ")); … … 1534 1535 newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1535 1536 plexesHeader = newtLabel(2, 2, headerstr); 1536 paranoid_free(headerstr);1537 mr_free(headerstr); 1537 1538 1538 1539 editraidForm = newtForm(NULL, NULL, 0); … … 1544 1545 switch (raidrec->plex[i].raidlevel) { 1545 1546 case -1: 1546 asprintf(&raidlevel, "concat");1547 mr_asprintf(&raidlevel, "concat"); 1547 1548 break; 1548 1549 case 0: 1549 asprintf(&raidlevel, "striped");1550 mr_asprintf(&raidlevel, "striped"); 1550 1551 break; 1551 1552 case 5: 1552 asprintf(&raidlevel, "raid5");1553 mr_asprintf(&raidlevel, "raid5"); 1553 1554 break; 1554 1555 default: 1555 asprintf(&raidlevel, "raid%i",1556 mr_asprintf(&raidlevel, "raid%i", 1556 1557 raidrec->plex[i].raidlevel); 1557 1558 break; … … 1559 1560 1560 1561 if (raidrec->plex[i].raidlevel == -1) { 1561 asprintf(&chunksize, "N/A");1562 mr_asprintf(&chunksize, "N/A"); 1562 1563 } else { 1563 asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);1564 mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize); 1564 1565 } 1565 asprintf(&pname, "%s.p%i", raidrec->volname, i);1566 asprintf(&entry, "%-14s %-8s %11s %8d",1566 mr_asprintf(&pname, "%s.p%i", raidrec->volname, i); 1567 mr_asprintf(&entry, "%-14s %-8s %11s %8d", 1567 1568 pname, raidlevel, chunksize, 1568 1569 raidrec->plex[i].subdisks); 1569 paranoid_free(pname);1570 paranoid_free(chunksize);1571 paranoid_free(raidlevel);1570 mr_free(pname); 1571 mr_free(chunksize); 1572 mr_free(raidlevel); 1572 1573 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1573 paranoid_free(entry);1574 mr_free(entry); 1574 1575 } 1575 1576 } … … 1592 1593 1593 1594 if (b_res == bDelete) { 1594 asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),1595 mr_asprintf(&msg, _("Are you sure you want to delete %s.p%i?"), 1595 1596 raidrec->volname, currline2); 1596 1597 if (ask_me_yes_or_no(msg)) { … … 1601 1602 raidrec->plexes--; 1602 1603 } 1603 paranoid_free(msg);1604 mr_free(msg); 1604 1605 continue; 1605 1606 } … … 1659 1660 memcpy((void *) bkp_raidrec, (void *) raidrec, 1660 1661 sizeof(struct raid_device_record)); 1661 asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);1662 mr_asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device); 1662 1663 log_msg(2, "Opening newt window"); 1663 1664 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1664 paranoid_free(title_of_editraidForm_window);1665 mr_free(title_of_editraidForm_window); 1665 1666 1666 1667 for (;;) { 1667 1668 log_msg(2, "Main loop"); 1668 asprintf(&sz_raid_level,1669 mr_asprintf(&sz_raid_level, 1669 1670 turn_raid_level_number_to_string(raidrec->raid_level)); 1670 asprintf(&sz_data_disks,1671 mr_asprintf(&sz_data_disks, 1671 1672 number_of_disks_as_string(raidrec->data_disks.entries, 1672 1673 _("data"))); 1673 asprintf(&sz_spare_disks,1674 mr_asprintf(&sz_spare_disks, 1674 1675 number_of_disks_as_string(raidrec->spare_disks.entries, 1675 1676 _("spare"))); 1676 asprintf(&sz_parity_disks,1677 mr_asprintf(&sz_parity_disks, 1677 1678 number_of_disks_as_string(raidrec->parity_disks.entries, 1678 1679 _("parity"))); 1679 asprintf(&sz_failed_disks,1680 mr_asprintf(&sz_failed_disks, 1680 1681 number_of_disks_as_string(raidrec->failed_disks.entries, 1681 1682 _("failed"))); … … 1685 1686 bSelectFailed = newtButton(20, 5, sz_failed_disks); 1686 1687 bChangeRaid = newtButton(1, 9, sz_raid_level); 1687 paranoid_free(sz_raid_level);1688 paranoid_free(sz_data_disks);1689 paranoid_free(sz_spare_disks);1690 paranoid_free(sz_parity_disks);1691 paranoid_free(sz_failed_disks);1688 mr_free(sz_raid_level); 1689 mr_free(sz_data_disks); 1690 mr_free(sz_spare_disks); 1691 mr_free(sz_parity_disks); 1692 mr_free(sz_failed_disks); 1692 1693 1693 1694 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _(" OK ")); … … 1735 1736 calculate_raid_device_size(mountlist, raidlist, 1736 1737 raidrec->raid_device); 1737 paranoid_free(bkp_raidrec);1738 mr_free(bkp_raidrec); 1738 1739 #endif 1739 1740 } … … 1792 1793 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1793 1794 sizeof(struct vinum_plex)); 1794 asprintf(&title_of_editraidForm_window, "%s.p%i",1795 mr_asprintf(&title_of_editraidForm_window, "%s.p%i", 1795 1796 raidlist->el[currline].volname, currline2); 1796 1797 newtPushHelpLine … … 1798 1799 (" Please select a subdisk to edit, or edit this plex's parameters")); 1799 1800 newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window); 1800 paranoid_free(title_of_editraidForm_window);1801 mr_free(title_of_editraidForm_window); 1801 1802 1802 1803 for (;;) { 1803 1804 switch (raidrec->raidlevel) { 1804 1805 case -1: 1805 asprintf(&tmp, "concat");1806 mr_asprintf(&tmp, "concat"); 1806 1807 break; 1807 1808 case 0: 1808 asprintf(&tmp, "striped");1809 mr_asprintf(&tmp, "striped"); 1809 1810 break; 1810 1811 case 5: 1811 asprintf(&tmp, "raid5");1812 mr_asprintf(&tmp, "raid5"); 1812 1813 break; 1813 1814 default: 1814 asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);1815 mr_asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel); 1815 1816 break; 1816 1817 } 1817 1818 bLevel = newtCompactButton(2, 2, _(" RAID level ")); 1818 1819 sLevel = newtLabel(19, 2, tmp); 1819 paranoid_free(tmp);1820 mr_free(tmp); 1820 1821 1821 1822 if (raidrec->raidlevel >= 0) { 1822 asprintf(&tmp, "%ik", raidrec->stripesize);1823 mr_asprintf(&tmp, "%ik", raidrec->stripesize); 1823 1824 bStripeSize = newtCompactButton(2, 4, _(" Stripe size ")); 1824 1825 } else { 1825 asprintf(&tmp, "N/A");1826 mr_asprintf(&tmp, "N/A"); 1826 1827 bStripeSize = newtLabel(2, 4, _("Stripe size:")); 1827 1828 } 1828 1829 sStripeSize = newtLabel(19, 4, tmp); 1829 paranoid_free(tmp);1830 mr_free(tmp); 1830 1831 1831 1832 bOK = newtCompactButton(2, 16, _(" OK ")); … … 1854 1855 keylist[i] = (void *) i; 1855 1856 if (i < raidrec->subdisks) { 1856 asprintf(&entry, "%-17s",1857 mr_asprintf(&entry, "%-17s", 1857 1858 find_dev_entry_for_raid_device_name(raidlist, 1858 1859 raidrec-> … … 1860 1861 which_device)); 1861 1862 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1862 paranoid_free(entry);1863 mr_free(entry); 1863 1864 } 1864 1865 if (i < unallocparts->entries) { 1865 asprintf(&entry, "%-17s", unallocparts->el[i].device);1866 mr_asprintf(&entry, "%-17s", unallocparts->el[i].device); 1866 1867 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1867 paranoid_free(entry);1868 mr_free(entry); 1868 1869 } 1869 1870 } … … 1915 1916 choose_raid_level(raidrec); 1916 1917 } else if (b_res == bStripeSize) { 1917 asprintf(&tmp, "%i", raidrec->stripesize);1918 mr_asprintf(&tmp, "%i", raidrec->stripesize); 1918 1919 if (popup_and_get_string 1919 1920 (_("Stripe size"), … … 1921 1922 raidrec->stripesize = atoi(tmp); 1922 1923 } 1923 paranoid_free(tmp);1924 mr_free(tmp); 1924 1925 } else if ((b_res == bAlloc) || (b_res == unallocListbox)) { 1925 1926 if (currline_u <= unallocparts->entries) … … 1969 1970 assert(lino >= 0); 1970 1971 1971 asprintf(&sz_out, raidrec->additional_vars.el[lino].value);1972 asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);1973 asprintf(&comment, _("Please set %s's value (currently '%s')"),1972 mr_asprintf(&sz_out, raidrec->additional_vars.el[lino].value); 1973 mr_asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label); 1974 mr_asprintf(&comment, _("Please set %s's value (currently '%s')"), 1974 1975 raidrec->additional_vars.el[lino].label, sz_out); 1975 1976 if (popup_and_get_string(header, comment, sz_out)) { 1976 paranoid_free(raidrec->additional_vars.el[lino].value);1977 mr_free(raidrec->additional_vars.el[lino].value); 1977 1978 raidrec->additional_vars.el[lino].value = sz_out; 1978 1979 } 1979 paranoid_free(header);1980 paranoid_free(comment);1980 mr_free(header); 1981 mr_free(comment); 1981 1982 } 1982 1983 #endif … … 2043 2044 bCancel = newtCompactButton(i += 12, 17, _("Cancel")); 2044 2045 bOK = newtCompactButton(i += 12, 17, _(" OK ")); 2045 asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"),2046 mr_asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), 2046 2047 _("Format"), _("Size (MB)")); 2047 2048 headerMsg = newtLabel(2, 1, tmp); … … 2064 2065 newtLabelSetText(flawsLabelC, flaws_str_C); 2065 2066 2066 paranoid_free(flaws_str_A);2067 paranoid_free(flaws_str_B);2068 paranoid_free(flaws_str_C);2067 mr_free(flaws_str_A); 2068 mr_free(flaws_str_B); 2069 mr_free(flaws_str_C); 2069 2070 2070 2071 b_res = newtRunForm(myForm); … … 2196 2197 memcpy((void *) &bkp_raidrec, (void *) raidrec, 2197 2198 sizeof(struct raid_device_record)); 2198 asprintf(&title_of_window, "Additional variables");2199 mr_asprintf(&title_of_window, "Additional variables"); 2199 2200 newtPushHelpLine 2200 2201 (_ … … 2211 2212 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2212 2213 newtOpenWindow(17, 7, 46, 10, title_of_window); 2213 paranoid_free(title_of_window);2214 mr_free(title_of_window); 2214 2215 2215 2216 myForm = newtForm(NULL, NULL, 0); … … 2306 2307 #ifdef __FreeBSD__ 2307 2308 for (i = 0; i < raidlist->entries; i++) { 2308 asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);2309 mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2309 2310 if (!strcmp(device, vdev)) { 2310 paranoid_free(vdev);2311 mr_free(vdev); 2311 2312 break; 2312 2313 } 2313 paranoid_free(vdev);2314 mr_free(vdev); 2314 2315 } 2315 2316 #else … … 2344 2345 // log_it("%d - AAA - isodir_path = %s", isodir_path); 2345 2346 if (isodir_device == NULL) { 2346 asprintf(&isodir_device, "/dev/");2347 mr_asprintf(&isodir_device, "/dev/"); 2347 2348 } 2348 2349 if (isodir_path == NULL) { 2349 asprintf(&isodir_path, "/");2350 mr_asprintf(&isodir_path, "/"); 2350 2351 } 2351 2352 if (does_file_exist("/tmp/NFS-SERVER-PATH")) { 2352 paranoid_free(isodir_device);2353 mr_free(isodir_device); 2353 2354 isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT"); 2354 asprintf(&isodir_format, "nfs");2355 paranoid_free(isodir_path);2355 mr_asprintf(&isodir_format, "nfs"); 2356 mr_free(isodir_path); 2356 2357 isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH"); 2357 2358 } … … 2415 2416 raidrec = &raidlist->el[pos_in_raidlist]; 2416 2417 initialize_raidrec(raidrec); 2417 asprintf(&raidrec->OSSWAP(raid_device, volname),2418 mr_asprintf(&raidrec->OSSWAP(raid_device, volname), 2418 2419 OSSWAP(device, basename(device))); 2419 2420 #ifndef __FreeBSD__ … … 2573 2574 } 2574 2575 for (i = 0; i < unallocated_raid_partitions->entries; i++) { 2575 asprintf(&tmp, "%-22s %8lld",2576 mr_asprintf(&tmp, "%-22s %8lld", 2576 2577 unallocated_raid_partitions->el[i].device, 2577 2578 unallocated_raid_partitions->el[i].size / 1024); 2578 2579 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2579 paranoid_free(tmp);2580 mr_free(tmp); 2580 2581 } 2581 2582 } … … 2610 2611 } 2611 2612 for (i = 0; i < additional_vars->entries; i++) { 2612 asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,2613 mr_asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label, 2613 2614 additional_vars->el[i].value); 2614 2615 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2615 paranoid_free(tmp);2616 mr_free(tmp); 2616 2617 } 2617 2618 } … … 2683 2684 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2684 2685 if (pos < 0) { 2685 asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",2686 mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", 2686 2687 old_dev); 2687 2688 log_it(tmp); 2688 paranoid_free(tmp);2689 mr_free(tmp); 2689 2690 } else { 2690 2691 if ((j = … … 2718 2719 #endif 2719 2720 else { 2720 asprintf(&tmp,2721 mr_asprintf(&tmp, 2721 2722 "%s is supposed to be listed in this raid dev but it's not...", 2722 2723 old_dev); 2723 2724 log_it(tmp); 2724 paranoid_free(tmp);2725 mr_free(tmp); 2725 2726 } 2726 2727 } … … 2833 2834 2834 2835 iamhere("Post-malloc"); 2835 asprintf(&help_text,2836 mr_asprintf(&help_text, 2836 2837 _ 2837 2838 (" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2838 asprintf(&header_text, "%-24s %s", _("Device"), _("Index"));2839 asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);2839 mr_asprintf(&header_text, "%-24s %s", _("Device"), _("Index")); 2840 mr_asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device); 2840 2841 newtPushHelpLine(help_text); 2841 paranoid_free(help_text);2842 mr_free(help_text); 2842 2843 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2843 2844 headerMsg = newtLabel(1, 1, header_text); … … 2896 2897 redraw_disklist(disklist, keylist, partitionsListbox); 2897 2898 } else { 2898 asprintf(&tmp, _("%s's index is %d. What should it be?"),2899 mr_asprintf(&tmp, _("%s's index is %d. What should it be?"), 2899 2900 raidrec->raid_device, 2900 2901 disklist->el[currline].index); 2901 asprintf(&sz_res, "%d", disklist->el[currline].index);2902 mr_asprintf(&sz_res, "%d", disklist->el[currline].index); 2902 2903 if (popup_and_get_string 2903 2904 (_("Set index"), tmp, sz_res)) { 2904 2905 disklist->el[currline].index = atoi(sz_res); 2905 2906 } 2906 paranoid_free(tmp);2907 paranoid_free(sz_res);2907 mr_free(tmp); 2908 mr_free(sz_res); 2908 2909 redraw_disklist(disklist, keylist, partitionsListbox); 2909 2910 } … … 2913 2914 newtPopWindow(); 2914 2915 } 2915 paranoid_free(title_of_window);2916 paranoid_free(header_text);2916 mr_free(title_of_window); 2917 mr_free(header_text); 2917 2918 2918 2919 newtPopHelpLine(); … … 2925 2926 sizeof(struct list_of_disks)); 2926 2927 } 2927 paranoid_free(bkp_raidrec);2928 paranoid_free(bkp_disklist);2929 paranoid_free(bkp_raidlist);2930 paranoid_free(unallocated_raid_partitions);2928 mr_free(bkp_raidrec); 2929 mr_free(bkp_disklist); 2930 mr_free(bkp_raidlist); 2931 mr_free(unallocated_raid_partitions); 2931 2932 } 2932 2933 #endif … … 2960 2961 (_ 2961 2962 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2962 getline(&tmp, &n, stdin);2963 } 2964 paranoid_free(tmp);2963 mr_getline(&tmp, &n, stdin); 2964 } 2965 mr_free(tmp); 2965 2966 return (output); 2966 2967 }
Note:
See TracChangeset
for help on using the changeset viewer.