Changeset 2274 in MondoRescue
- Timestamp:
- Jul 13, 2009, 2:34:28 AM (16 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-string.c
r2242 r2274 944 944 malloc_string(reason); 945 945 malloc_string(filename); 946 // out_reason might be null on purpose, so don't bomb if it is :) OK? 946 947 // out_reason might be null on purpose, so don't bomb if it is :) OK? 947 948 assert_string_is_neither_NULL_nor_zerolength(fn); 948 949 if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) { -
branches/2.2.10/mondo/src/common/newt-specific.c
r2241 r2274 985 985 986 986 /*@ buffers ********************************************************** */ 987 char *timeline_str ;987 char *timeline_str = NULL; 988 988 char *pcline_str = NULL; 989 989 char *taskprogress = NULL; … … 994 994 int j = 0; 995 995 996 malloc_string(timeline_str);997 timeline_str[0] = '\0';998 // log_it("update_eval_call_form called");999 996 if (num * 100 < denom) { 1000 997 percentage = 1; … … 1020 1017 || percentage > g_isoform_old_progress) { 1021 1018 g_isoform_old_progress = percentage; 1022 sprintf(timeline_str,1019 mr_asprintf(&timeline_str, 1023 1020 "%2ld:%02ld taken %2ld:%02ld remaining", 1024 1021 time_taken / 60, time_taken % 60, time_remaining / 60, … … 1064 1061 } 1065 1062 } 1066 paranoid_free(pcline_str); 1063 mr_free(pcline_str); 1064 mr_free(timeline_str); 1067 1065 } 1068 1066 if (!g_text_mode) { … … 1070 1068 newtRefresh(); 1071 1069 } 1072 paranoid_free(timeline_str);1073 1070 } 1074 1071 … … 1123 1120 1124 1121 /*@ buffers *************************************************** */ 1125 char *percentline_str ;1126 char *timeline_str ;1122 char *percentline_str = NULL; 1123 char *timeline_str = NULL; 1127 1124 char *taskprogress = NULL; 1128 char *tmp; 1129 1130 // log_msg(1, "'%s' '%s' '%s'", blurb1, blurb2, blurb3); 1131 percentline_str = malloc(MAX_NEWT_COMMENT_LEN); 1132 timeline_str = malloc(MAX_NEWT_COMMENT_LEN); 1133 malloc_string(tmp); 1125 char *tmp = NULL; 1126 1134 1127 if (!g_text_mode) { 1135 1128 assert(blurb1 != NULL); … … 1139 1132 } 1140 1133 1141 percentline_str[0] = '\0';1142 1143 1134 current_time = get_time(); 1144 1135 time_taken = current_time - g_start_time; … … 1147 1138 } else { 1148 1139 if (g_current_progress > g_maximum_progress) { 1149 sprintf(tmp,1140 mr_asprintf(&tmp, 1150 1141 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", 1151 1142 blurb1, blurb2, blurb3, g_current_progress, 1152 1143 g_maximum_progress); 1153 1144 log_msg(0, tmp); 1145 mr_free(tmp); 1154 1146 g_current_progress = g_maximum_progress; 1155 1147 } … … 1172 1164 } 1173 1165 g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27; 1174 sprintf(timeline_str,1175 "%2ld:%02ld taken %2ld:%02ld remaining ",1176 time_taken / 60, time_taken % 60, time_remaining / 60,1177 time_remaining % 60);1178 sprintf(percentline_str, " %3d%% done %3d%% to go",1179 percentage, 100 - percentage);1180 1181 1166 if (g_text_mode) { 1182 1167 printf("---progress-form---1--- %s\n", blurb1); … … 1200 1185 paranoid_free(taskprogress); 1201 1186 } else { 1187 mr_asprintf(&timeline_str, 1188 "%2ld:%02ld taken %2ld:%02ld remaining ", 1189 time_taken / 60, time_taken % 60, time_remaining / 60, 1190 time_remaining % 60); 1191 mr_asprintf(percentline_str, " %3d%% done %3d%% to go", 1192 percentage, 100 - percentage); 1193 1202 1194 center_string(blurb1, 54); 1203 1195 center_string(blurb2, 54); … … 1216 1208 newtLabelSetText(g_timeline, timeline_str); 1217 1209 } 1210 mr_free(timeline_str); 1211 1218 1212 if (g_percentline) { 1219 1213 newtLabelSetText(g_percentline, percentline_str); 1220 1214 } 1215 mr_free(percentline_str); 1216 1221 1217 newtRefresh(); 1222 1218 } 1223 paranoid_free(percentline_str);1224 paranoid_free(timeline_str);1225 paranoid_free(tmp);1226 1219 } 1227 1220 … … 1579 1572 1580 1573 /*@ buffers ********************************************************* */ 1581 char *tmp ;1582 char *differ_sz ;1574 char *tmp = NULL; 1575 char *differ_sz = NULL; 1583 1576 1584 1577 struct s_filelist *filelist; 1585 malloc_string(reason);1586 tmp = malloc(5000);1587 malloc_string(differ_sz);1588 1578 assert_string_is_neither_NULL_nor_zerolength(source_file); 1589 1579 if (g_text_mode) { 1590 1580 log_msg(2, "Text mode. Therefore, no popup list."); 1591 goto free_to_go;1581 return; 1592 1582 } 1593 1583 log_msg(2, "Examining file %s", source_file); … … 1596 1586 if (lng < 1) { 1597 1587 log_msg(2, "No lines in file. Therefore, no popup list."); 1598 paranoid_free(reason); 1599 goto free_to_go; 1588 return; 1600 1589 } else if (lng >= ARBITRARY_MAXIMUM) { 1601 1590 log_msg(2, "Too many files differ for me to list."); 1602 goto free_to_go;1591 return; 1603 1592 } 1604 1593 … … 1609 1598 1610 1599 if (load_filelist_into_array(filelist, source_file)) { 1611 log_msg(2, "Can't open %s; therefore, cannot popup list", 1612 source_file); 1613 paranoid_free(reason); 1600 log_msg(2, "Can't open %s; therefore, cannot popup list", source_file); 1614 1601 return; 1615 1602 } … … 1624 1611 keylist[i]); 1625 1612 } 1626 sprintf(differ_sz,1613 mr_asprintf(&differ_sz, 1627 1614 " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", 1628 1615 i); 1629 1616 newtPushHelpLine(differ_sz); 1617 mr_free(differ_sz); 1618 1630 1619 bClose = newtCompactButton(10, 15, " Close "); 1631 1620 bSelect = newtCompactButton(30, 15, " Select "); 1632 sprintf(tmp, "%-10s %-20s", "Priority", "Filename");1621 mr_asprintf(&tmp, "%-10s %-20s", "Priority", "Filename"); 1633 1622 headerMsg = newtLabel(2, 1, tmp); 1623 mr_free(tmp); 1624 1634 1625 newtOpenWindow(5, 4, 70, 16, "Non-matching files"); 1635 1626 myForm = newtForm(NULL, NULL, 0); 1636 1627 newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, 1637 1628 bSelect, NULL); 1629 1630 malloc_string(reason); 1638 1631 while (!finished) { 1639 1632 b_res = newtRunForm(myForm); … … 1650 1643 currline = i; 1651 1644 if (filelist->entries > 0) { 1652 severity_of_difference(filelist->el[currline]. 1653 filename, reason); 1654 sprintf(tmp, "%s --- %s", 1655 filelist->el[currline].filename, reason); 1645 severity_of_difference(filelist->el[currline]. filename, reason); 1646 mr_asprintf(&tmp, "%s --- %s", filelist->el[currline].filename, reason); 1647 1656 1648 popup_and_OK(tmp); 1649 mr_free(tmp); 1657 1650 } 1658 1651 } 1659 1652 } 1660 1653 } 1654 paranoid_free(reason); 1655 1661 1656 newtFormDestroy(myForm); 1662 1657 newtPopWindow(); 1663 1658 newtPopHelpLine(); 1664 free_to_go:1665 paranoid_free(reason);1666 paranoid_free(tmp);1667 paranoid_free(differ_sz);1668 1659 return; 1669 1660 }
Note:
See TracChangeset
for help on using the changeset viewer.