Ignore:
Timestamp:
Sep 25, 2013, 8:55:39 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Backport tons of dynamic memory management rewrite from 3.1 branch. Test is needed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/newt-specific.c

    r3185 r3188  
    9797    extern int g_current_media_number;
    9898    pid_t g_main_pid = 0;       ///< The PID of the main Mondo process.
    99     long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
     99    long g_maximum_progress = 999L; ///< The maximum amount of progress (100%) for the currently opened progress form.
    100100    long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
    101     long g_start_time = 0;      ///< The time (in seconds since the epoch) that the progress form was opened.
     101    long g_start_time = 0L;     ///< The time (in seconds since the epoch) that the progress form was opened.
    102102    bool g_text_mode = TRUE;    ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
    103     char g_xmondo_stdin[MAX_NEWT_COMMENT_LEN],  ///< ... @bug Unneeded w/current XMondo.
    104      g_xmondo_stdout[MAX_NEWT_COMMENT_LEN]; ///< .... @bug Unneeded w/current XMondo.
    105     bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
    106103    char *g_selfmounted_isodir; ///< Holds the NETFS mountpoint if mounted via mondoarchive.
    107104
    108105/* @} - end of globalGroup */
    109 
    110 //int g_fd_in=-1, g_fd_out=-1;
    111106
    112107    void popup_and_OK(char *);
     
    125120
    126121        /*@ buffers ********************************************************** */
    127         int i;
    128         char *p;
     122        int i = 0;
     123        char *tmp = NULL;
    129124
    130125        assert_string_is_neither_NULL_nor_zerolength(prompt);
     
    136131        }
    137132        if (g_text_mode) {
    138 
    139             char *tmp;
    140             tmp = malloc(MAX_NEWT_COMMENT_LEN);
    141 
    142133            while (1) {
    143                 paranoid_system("sync");
    144                 printf
    145                     ("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ",
    146                      prompt);
    147                 p= fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
    148                 if (!p) {
    149                     //FIXME
    150                 }
     134                sync();
     135                printf("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ", prompt);
     136                mr_getline(tmp, stdin);
    151137                if (tmp[strlen(tmp) - 1] == '\n')
    152138                    tmp[strlen(tmp) - 1] = '\0';
     
    157143                }
    158144                if (strstr("yesYES", tmp)) {
    159                     paranoid_free(tmp);
     145                    mr_free(tmp);
    160146                    return (TRUE);
    161147                } else if (strstr("NOno", tmp)) {
    162                     paranoid_free(tmp);
     148                    mr_free(tmp);
    163149                    return (FALSE);
    164150                } else {
    165                     paranoid_system("sync");
    166                     printf
    167                         ("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
     151                    sync();
     152                    printf("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
    168153                }
    169154            }
     
    183168
    184169        /*@ buffer *********************************************************** */
    185         char *tmp;
    186         char *p;
     170        char *tmp = NULL;
    187171        int i;
    188172
     
    193177            finish(1);
    194178        }
    195         tmp = malloc(MAX_NEWT_COMMENT_LEN);
     179
    196180        if (g_text_mode) {
    197             paranoid_system("sync");
    198             printf
    199                 ("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ",
    200                  prompt);
    201             p = fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
    202             if (!p) {
    203                 // FIXME
    204             }
     181            sync();
     182            printf("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ", prompt);
     183            mr_getline(tmp, stdin);
    205184            if (tmp[strlen(tmp) - 1] == '\n')
    206185                tmp[strlen(tmp) - 1] = '\0';
     
    211190            }
    212191            if (strstr("okOKOkYESyes", tmp)) {
    213                 paranoid_free(tmp);
     192                mr_free(tmp);
    214193                return (TRUE);
    215194            } else {
    216                 paranoid_free(tmp);
     195                mr_free(tmp);
    217196                return (FALSE);
    218197            }
    219198        } else {
    220             paranoid_free(tmp);
    221199            return (popup_with_buttons(prompt, " Okay ", "Cancel"));
    222200        }
     
    264242        }
    265243        if (g_current_progress == -999) {
    266             log_msg(2,
    267                     "Trying to close the progress form when it ain't open!");
     244            log_msg(2, "Trying to close the progress form when it ain't open!");
    268245            return;
    269246        }
     
    301278        mr_asprintf(tmp1,"kill `%s`", tmp);
    302279        run_program_and_log_output(tmp1, TRUE);
    303         paranoid_free(tmp1);
    304     }
    305     paranoid_free(tmp);
     280        mr_free(tmp1);
     281    }
     282    mr_free(tmp);
    306283}
    307284
     
    312289 * @note This function never returns.
    313290 */
    314     void
    315      fatal_error(char *error_string) {
     291void fatal_error(char *error_string) {
     292
    316293        /*@ buffers ***************************************************** */
    317         char fatalstr[MAX_NEWT_COMMENT_LEN] =
    318             "-------FATAL ERROR---------";
    319         char *tmp;
    320         char *command;
     294        char *command = NULL;
    321295        static bool already_exiting = FALSE;
    322296
    323297        /*@ end vars **************************************************** */
    324298
    325         malloc_string(command);
    326         tmp = malloc(MAX_NEWT_COMMENT_LEN);
    327299        set_signals(FALSE);     // link to external func
    328300        g_exiting = TRUE;
     
    332304            log_msg(2, "mastermind %d is exiting", (int) getpid());
    333305            kill(g_main_pid, SIGTERM);
    334             paranoid_free(tmp);
    335306            finish(1);
    336307        }
     
    340311                log_msg(2, "non-m/m %d is exiting", (int) getpid());
    341312                kill(g_main_pid, SIGTERM);
    342                 paranoid_free(tmp);
    343313                finish(1);
    344314            }
     
    348318        if (already_exiting) {
    349319            log_msg(3, "...I'm already exiting. Give me time, Julian!");
    350             paranoid_free(tmp);
    351320            finish(1);
    352321        }
     
    359328        kill_anything_like_this("ntfsclone");
    360329        sync();
    361         /*
    362         sprintf(tmp, "umount %s", g_tmpfs_mountpt);
    363         for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
    364             log_msg(2, "Waiting for child processes to terminate");
    365             sleep(1);
    366             run_program_and_log_output(tmp, 5);
    367         }
    368         */
    369330
    370331        if (chdir("/")) {
     
    372333        }
    373334        if (g_selfmounted_isodir) {
    374             sprintf(command, "umount -d %s", g_selfmounted_isodir);
     335            mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
    375336            run_program_and_log_output(command, 5);
    376             sprintf(command, "rmdir %s", g_selfmounted_isodir);
     337            mr_free(command);
     338            mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
    377339            run_program_and_log_output(command, 5);
     340            mr_free(command);
    378341        }
    379342
    380343        if (!g_text_mode) {
    381             log_msg(0, fatalstr);
     344            log_msg(0, "-------FATAL ERROR---------");
    382345            log_msg(0, error_string);
    383             //      popup_and_OK (error_string);
    384             newtFinished();
    385346        }
    386347
    387348        printf("---FATALERROR--- %s\n", error_string);
    388         printf
    389                 ("If you require technical support, please contact the mailing list.\n");
     349        printf("If you require technical support, please contact the mailing list.\n");
    390350        printf("See http://www.mondorescue.org for details.\n");
    391         printf
    392                 ("The list's members can help you, if you attach that file to your e-mail.\n");
     351        printf("The list's members can help you, if you attach that file to your e-mail.\n");
    393352        printf("Log file: %s\n", MONDO_LOGFILE);
    394353        printf("Mondo has aborted.\n");
     
    396355            log_msg(3, "FYI - g_main_pid is blank");
    397356        }
    398         paranoid_free(tmp);
    399         paranoid_free(command);
    400357        finish(254);
    401358    }
     
    420377 * @note This function never returns.
    421378 */
    422     void
    423      finish(int signal) {
     379void finish(int signal) {
     380
    424381        char *command = NULL;
    425 
    426         /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
    427 
    428         /* newtPopHelpLine(); */
    429382
    430383        /*  Before removing dir, make sure we're out of them */
     
    436389            mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
    437390            run_program_and_log_output(command, 1);
    438             paranoid_free(command);
     391            mr_free(command);
     392
    439393            mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
    440394            run_program_and_log_output(command, 1);
    441             paranoid_free(command);
    442         }
     395            mr_free(command);
     396        }
     397        if (bkpinfo->tmpdir) {
     398            log_msg(8,"tempdir is %s",bkpinfo->tmpdir);
     399            if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
     400                log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir);
     401                mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir);
     402                paranoid_system(command);
     403                mr_free(command);
     404            }
     405        }
     406        if (bkpinfo->scratchdir) {
     407            log_msg(8,"scratchdir is %s", bkpinfo->scratchdir);
     408            if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) {
     409                log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir);
     410                mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir);
     411                paranoid_system(command);
     412                mr_free(command);
     413            }
     414        }
     415        /* Free all allocated strings in bkpinfo */
     416        mr_free(bkpinfo->netfs_user);
     417        mr_free(bkpinfo->netfs_proto);
     418        mr_free(bkpinfo->exclude_devs);
     419        mr_free(bkpinfo->exclude_paths);
     420        mr_free(bkpinfo->subdir);
     421        /* Then free the structure */
     422        paranoid_free(bkpinfo);
     423
     424        free_libmondo_global_strings();
     425        free_newt_stuff();
    443426        if (!g_text_mode) {
    444427            if (does_file_exist("/THIS-IS-A-RAMDISK")) {
     
    452435        printf("Execution run ended; result=%d\n", signal);
    453436        printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    454         if (bkpinfo->tmpdir) {
    455             log_msg(8,"tempdir is %s",bkpinfo->tmpdir);
    456             if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
    457                 log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir);
    458                 mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir);
    459                 paranoid_system(command);
    460                 mr_free(command);
    461             }
    462         }
    463         if (bkpinfo->scratchdir) {
    464             log_msg(8,"scratchdir is %s", bkpinfo->scratchdir);
    465             if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) {
    466                 log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir);
    467                 mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir);
    468                 paranoid_system(command);
    469                 mr_free(command);
    470             }
    471         }
    472         /* Free all allocated strings in bkpinfo */
    473         mr_free(bkpinfo->netfs_user);
    474         mr_free(bkpinfo->netfs_proto);
    475         mr_free(bkpinfo->exclude_devs);
    476         mr_free(bkpinfo->exclude_paths);
    477         mr_free(bkpinfo->subdir);
    478 
    479         /* Then free the structure */
    480         paranoid_free(bkpinfo);
    481         free_libmondo_global_strings();
    482         free_newt_stuff();
    483437        exit(signal);
    484438    }
    485 
    486 
    487 
    488439
    489440
     
    494445 * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression.
    495446 */
    496     void
    497      log_file_end_to_screen(char *filename, char *grep_for_me) {
     447void log_file_end_to_screen(char *filename, char *grep_for_me) {
    498448
    499449        /*@ buffers ********************************************************** */
     
    515465        }
    516466        if (grep_for_me[0] != '\0') {
    517             mr_asprintf(command, "grep '%s' %s | tail -n%d",
    518                     grep_for_me, filename, g_noof_log_lines);
    519         } else {
    520             mr_asprintf(command, "tail -n%d %s", g_noof_log_lines,
    521                     filename);
     467            mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
     468        } else {
     469            mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
    522470        }
    523471        fin = popen(command, "r");
     
    557505 * @note The message is also written to the logfile.
    558506 */
    559     void
    560      log_to_screen(const char *fmt, ...) {
     507void log_to_screen(const char *fmt, ...) {
    561508
    562509        /*@ int ************************************************************** */
     
    614561 * @param output The string to write.
    615562 */
    616     void
    617      mvaddstr_and_log_it(int y, int x, char *output) {
     563void mvaddstr_and_log_it(int y, int x, char *output) {
     564
    618565        assert_string_is_neither_NULL_nor_zerolength(output);
    619566        log_msg(0, output);
     
    633580 * @param ttl The title to use for the evalcall form.
    634581 */
    635     void
    636      open_evalcall_form(char *ttl) {
     582void open_evalcall_form(char *ttl) {
    637583
    638584        /*@ buffers ********************************************************* */
    639         char *title;
    640         char *tmp;
     585        char *tmp = NULL;
    641586
    642587        /*@ initialize ****************************************************** */
    643588        g_isoform_old_progress = -1;
    644589        g_mysterious_dot_counter = 0;
    645         malloc_string(title);
     590
     591        assert(ttl != NULL);
    646592        malloc_string(tmp);
    647 
    648         assert(ttl != NULL);
    649         strcpy(title, ttl);
    650         strcpy(g_isoform_header_str, title);
    651 //  center_string (title, 80);
     593        strcpy(g_isoform_header_str, ttl);
    652594        if (g_text_mode) {
    653             log_msg(0, title);
    654         } else {
    655             strcpy(tmp, title);
     595            log_msg(0, ttl);
     596        } else {
     597            strcpy(tmp, ttl);
    656598            center_string(tmp, 80);
    657599            newtPushHelpLine(tmp);
     
    664606            g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
    665607            g_isoform_scale = newtScale(3, 3, 34, 100);
    666             //      newtOpenWindow (20, 6, 40, 7, title);      // "Please Wait");
    667             newtCenteredWindow(40, 7, title);
     608            newtCenteredWindow(40, 7, ttl);
    668609            g_isoform_main = newtForm(NULL, NULL, 0);
    669610            g_isoform_timeline = newtLabel(1, 5, "                    ");
     
    677618        update_evalcall_form(0);
    678619        paranoid_free(tmp);
    679         paranoid_free(title);
    680620    }
    681621
     
    691631 * @param max_val The maximum amount of progress (number of filesets, etc.)
    692632 */
    693     void
    694      open_progress_form(char *title, char *b1, char *b2, char *b3,
    695                         long max_val) {
     633void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) {
    696634
    697635        /*@ buffers ********************************************************* */
    698636        char *b1c;
    699         char *blurb1;
    700         char *blurb2;
    701         char *blurb3;
     637        char *blurb1 = NULL;
     638        char *blurb2 = NULL;
     639        char *blurb3 = NULL;
    702640
    703641        /*@ initialize ****************************************************** */
     
    705643
    706644        malloc_string(b1c);
    707         malloc_string(blurb1);
    708         malloc_string(blurb2);
    709         malloc_string(blurb3);
    710645
    711646        assert(title != NULL);
     
    714649        assert(b3 != NULL);
    715650
    716         strcpy(blurb1, b1);
    717         strcpy(blurb2, b2);
    718         strcpy(blurb3, b3);
     651        mr_asprintf(blurb1,  "%s", b1);
     652        mr_asprintf(blurb2,  "%s", b2);
     653        mr_asprintf(blurb3,  "%s", b3);
     654
    719655        strcpy(b1c, b1);
    720656        center_string(b1c, 80);
     
    737673            g_blurb2 = newtLabel(2, 2, blurb3);
    738674            g_blurb3 = newtLabel(2, 4, blurb2);
    739             //      newtOpenWindow (10, 4, 60, 11, title);
    740675            newtCenteredWindow(60, 11, title);
    741             g_scale = newtScale(3, 6, 54, g_maximum_progress);
     676            g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress);
    742677            g_progressForm = newtForm(NULL, NULL, 0);
    743678            g_percentline = newtLabel(10, 9, "                       ");
    744679            g_timeline = newtLabel(10, 8, "                    ");
    745             newtFormAddComponents(g_progressForm, g_percentline,
    746                                   g_timeline, g_scale, g_blurb1, g_blurb3,
    747                                   g_blurb2, NULL);
     680            newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL);
    748681            newtPushHelpLine(b1c);
    749682            newtDrawForm(g_progressForm);
     
    752685        update_progress_form_full(blurb1, blurb2, blurb3);
    753686        paranoid_free(b1c);
    754         paranoid_free(blurb1);
    755         paranoid_free(blurb2);
    756         paranoid_free(blurb3);
     687        mr_free(blurb1);
     688        mr_free(blurb2);
     689        mr_free(blurb3);
    757690    }
    758691
     
    761694 * @param prompt The message.
    762695 */
    763     void
    764      popup_and_OK(char *prompt) {
     696void popup_and_OK(char *prompt) {
     697
    765698        char ch;
    766699
     
    769702        log_msg(0, prompt);
    770703        if (g_text_mode) {
    771             printf
    772                 ("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ",
    773                  prompt);
     704            printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt);
    774705            while (((ch = getchar()) != '\n') && (ch != EOF));
    775706        } else {
     
    786717 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
    787718 */
    788     bool popup_and_get_string(char *title, char *b, char *output,
    789                               int maxsize) {
     719    bool popup_and_get_string(char *title, char *b, char *output, int maxsize) {
    790720
    791721        /*@ newt ************************************************************ */
     
    801731
    802732        /*@ buffers ********************************************************** */
    803         char *blurb;
     733        char *blurb = NULL;
    804734        char *p;
    805         char *original_contents;
    806 
    807         blurb = malloc(MAX_NEWT_COMMENT_LEN);
    808         original_contents = malloc(MAX_NEWT_COMMENT_LEN);
     735        char *original_contents = NULL;
     736
    809737        assert_string_is_neither_NULL_nor_zerolength(title);
    810738        assert(b != NULL);
     
    812740
    813741        if (g_text_mode) {
    814             printf
    815                 ("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ",
    816                  title, b);
     742            printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ", title, b);
    817743            p = fgets(output, maxsize, stdin);
    818744            if (!p) {
     
    821747            if (output[strlen(output) - 1] == '\n')
    822748                output[strlen(output) - 1] = '\0';
    823             paranoid_free(blurb);
    824             paranoid_free(original_contents);
    825749            return (TRUE);
    826750        }
     751       
     752        blurb = malloc(MAX_NEWT_COMMENT_LEN);
    827753        strcpy(blurb, b);
    828754        text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    829         strcpy(original_contents, output);
     755        mr_asprintf(original_contents, "%s", output);
    830756        output[0] = '\0';
    831         type_here =
    832             newtEntry(2, newtTextboxGetNumLines(text) + 2,
    833                       original_contents, 50,
     757        type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, original_contents, 50,
    834758#ifdef __cplusplus
    835759                      0, NEWT_FLAG_RETURNEXIT
     
    840764        b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, "  OK  ");
    841765        b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
    842         //  newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);
    843766        newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
    844767        myForm = newtForm(NULL, NULL, 0);
     
    851774        newtFormDestroy(myForm);
    852775        newtPopWindow();
     776        paranoid_free(blurb);
     777
    853778        if (b_res == b_2) {
    854779            strcpy(output, original_contents);
    855             paranoid_free(blurb);
    856             paranoid_free(original_contents);
     780            mr_free(original_contents);
    857781            return (FALSE);
    858782        } else {
    859             paranoid_free(blurb);
    860             paranoid_free(original_contents);
     783            mr_free(original_contents);
    861784            return (TRUE);
    862785        }
     
    871794 * @return TRUE if @p button1 was pushed, FALSE otherwise.
    872795 */
    873     bool popup_with_buttons(char *p, char *button1, char *button2) {
     796bool popup_with_buttons(char *p, char *button1, char *button2) {
    874797
    875798        /*@ buffers *********************************************************** */
    876         char *prompt;
    877         char *q;
     799        char *prompt = NULL;
    878800
    879801        /*@ newt ************************************************************** */
     
    887809        assert(button1 != NULL);
    888810        assert(button2 != NULL);
    889         prompt = malloc(MAX_NEWT_COMMENT_LEN);
    890811        if (g_text_mode) {
    891812            if (strlen(button2) == 0) {
     
    894815                printf("%s (%s or %s) --> ", p, button1, button2);
    895816            }
    896             for (prompt[0] = '\0';
    897                  strcmp(prompt, button1) && (strlen(button2) == 0
    898                                           || strcmp(prompt, button2));) {
     817            mr_getline(prompt, stdin);
     818            while (strcmp(prompt, button1) && (strlen(button2) == 0 || strcmp(prompt, button2))) {
    899819                printf("--> ");
    900                 q = fgets(prompt, MAX_NEWT_COMMENT_LEN, stdin);
    901                 if (!q) {
    902                     // FIXME
    903                 }
     820                mr_free(prompt);
     821                mr_getline(prompt, stdin);
    904822            }
    905823            if (!strcmp(prompt, button1)) {
    906                 paranoid_free(prompt);
     824                mr_free(prompt);
    907825                return (TRUE);
    908826            } else {
    909                 paranoid_free(prompt);
     827                mr_free(prompt);
    910828                return (FALSE);
    911829            }
    912830        }
    913831
     832        prompt = malloc(MAX_NEWT_COMMENT_LEN);
    914833        strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    915834        prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    916835        text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    917         b_1 =
    918             newtButton(20 -
    919                        ((button2[0] !=
    920                          '\0') ? strlen(button1) +
    921                         2 : strlen(button1) / 2),
    922                        newtTextboxGetNumLines(text) + 3, button1);
     836        b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
    923837        if (button2[0] != '\0') {
    924             b_2 =
    925                 newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
     838            b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
    926839        } else {
    927840            b_2 = NULL;
    928841        }
    929         //  newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");
    930842        newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
    931843        myForm = newtForm(NULL, NULL, 0);
     
    953865 * on the screen.
    954866 */
    955     void
    956      refresh_log_screen() {
     867void refresh_log_screen() {
    957868
    958869        /*@ int *********************************************************** */
     
    981892 * only allocate some memory.
    982893 */
    983     void
    984      setup_newt_stuff() {
     894void setup_newt_stuff() {
    985895
    986896        /*@ int *********************************************************** */
     
    991901            newtInit();
    992902            newtCls();
    993             newtPushHelpLine
    994                 ("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
    995             /*  newtDrawRootText(28,0,"Welcome to Mondo Rescue"); */
     903            newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
    996904            newtDrawRootText(18, 0, WELCOME_STRING);
    997905            newtRefresh();
     
    1000908        }
    1001909
    1002         err_log_lines =
    1003             (char **) malloc(sizeof(char *) * g_noof_log_lines);
    1004         if (!err_log_lines) {
    1005             fatal_error("Out of memory");
    1006         }
     910        err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
    1007911
    1008912        for (i = 0; i < g_noof_log_lines; i++) {
    1009             err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN);
    1010             if (!err_log_lines[i]) {
    1011                 fatal_error("Out of memory");
    1012             }
     913            err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
    1013914        }
    1014915
     
    1024925 * @param denom The denomenator of the ratio.
    1025926 */
    1026     void
    1027      update_evalcall_form_ratio(int num, int denom) {
     927void update_evalcall_form_ratio(int num, int denom) {
    1028928
    1029929        /*@ long ************************************************************ */
    1030         long current_time = 0;
    1031         long time_taken = 0;
    1032         long time_total_est = 0;
    1033         long time_remaining = 0;
     930        long current_time = 0L;
     931        long time_taken = 0L;
     932        long time_total_est = 0L;
     933        long time_remaining = 0L;
    1034934
    1035935        /*@ buffers ********************************************************** */
    1036         char *timeline_str;
     936        char *timeline_str = NULL;
    1037937        char *pcline_str = NULL;
    1038938        char *taskprogress = NULL;
     
    1043943        int j = 0;
    1044944
    1045         malloc_string(timeline_str);
    1046         timeline_str[0] = '\0';
    1047 //  log_it("update_eval_call_form called");
    1048945        if (num * 100 < denom) {
    1049946            percentage = 1;
     
    1058955            time_remaining = time_total_est - time_taken;
    1059956        } else {
    1060             time_remaining = 0;
     957            time_remaining = 0L;
    1061958        }
    1062959        if (!g_text_mode) {
     
    1069966            || percentage > g_isoform_old_progress) {
    1070967            g_isoform_old_progress = percentage;
    1071             sprintf(timeline_str,
    1072                     "%2ld:%02ld taken            %2ld:%02ld remaining",
    1073                     (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60,
    1074                     (long) time_remaining % 60);
     968            mr_asprintf(timeline_str, "%2ld:%02ld taken            %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
    1075969            if (percentage < 3) {
    1076970                mr_asprintf(pcline_str, " Working");
     
    1083977                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    1084978            } else {
    1085                 mr_asprintf(pcline_str, " %3d%% done              %3d%% to go",
    1086                         percentage, 100 - percentage);
     979                mr_asprintf(pcline_str, " %3d%% done              %3d%% to go", percentage, 100 - percentage);
    1087980            }
    1088981            if (g_text_mode) {
     
    1095988                }
    1096989                if (percentage >= 3) {
    1097                     mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
    1098                             (long) time_remaining / 60, (long) time_remaining % 60);
    1099                     printf("---evalcall---1--- %s\n",
    1100                            g_isoform_header_str);
     990                    mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
     991                    printf("---evalcall---1--- %s\n", g_isoform_header_str);
    1101992                    printf("---evalcall---2--- %s\n", taskprogress);
    1102993                    printf("---evalcall---E---\n");
    1103994                }
    1104                 paranoid_free(taskprogress);
     995                mr_free(taskprogress);
    1105996            } else {
    1106                 newtScaleSet(g_isoform_scale,
    1107                              (unsigned long long) percentage);
     997                newtScaleSet(g_isoform_scale, (unsigned long long) percentage);
    1108998                if (g_isoform_pcline) {
    1109999                    newtLabelSetText(g_isoform_pcline, pcline_str);
     
    11131003                }
    11141004            }
    1115             paranoid_free(pcline_str);
     1005            mr_free(pcline_str);
     1006            mr_free(timeline_str);
    11161007        }
    11171008        if (!g_text_mode) {
    1118 //      log_it("refreshing");
    11191009            newtDrawForm(g_isoform_main);
    11201010            newtRefresh();
    11211011        }
    1122         paranoid_free(timeline_str);
    11231012    }
    11241013
     
    11291018 * @param curr The current amount of progress (percentage) in the evalcall form.
    11301019 */
    1131     void
    1132      update_evalcall_form(int curr) {
     1020void update_evalcall_form(int curr) {
     1021
    11331022        update_evalcall_form_ratio(curr, 100);
    1134     }
     1023}
    11351024
    11361025
     
    11411030 * @param blurb3 The new third line of the blurb; use @p g_blurb_str_2 (no, that's not a typo) to keep it the same.
    11421031 */
    1143     void
    1144      update_progress_form(char *blurb3) {
    1145         /*  log_it("update_progress_form --- called"); */
     1032void update_progress_form(char *blurb3) {
     1033
    11461034        if (g_current_progress == -999) {
    1147             /* log_it("You're trying to update progress form when it ain't open. Aww, that's OK. I'll let it go. It's a bit naughty but it's a nonfatal error. No prob, Bob."); */
    11481035            return;
    11491036        }
    11501037        strcpy(g_blurb_str_2, blurb3);
    1151         update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
    1152                                   g_blurb_str_3);
    1153     }
     1038        update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3);
     1039}
    11541040
    11551041
     
    11601046 * @param blurb3 The third line of the blurb. Use @p g_blurb_str_2 (no, that's not a typo either) to keep it the same.
    11611047 */
    1162     void
    1163      update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
     1048void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
     1049
    11641050        /*@ long ***************************************************** */
    11651051        long current_time = 0L;
     
    11731059
    11741060        /*@ buffers *************************************************** */
    1175         char *percentline_str;
    1176         char *timeline_str;
     1061        char *percentline_str = NULL;
     1062        char *timeline_str = NULL;
    11771063        char *taskprogress = NULL;
    1178         char *tmp;
    1179 
    1180 //  log_msg(1, "'%s' '%s' '%s'", blurb1, blurb2, blurb3);
    1181         percentline_str = malloc(MAX_NEWT_COMMENT_LEN);
    1182         timeline_str = malloc(MAX_NEWT_COMMENT_LEN);
    1183         malloc_string(tmp);
     1064
    11841065        if (!g_text_mode) {
    11851066            assert(blurb1 != NULL);
     
    11891070        }
    11901071
    1191         percentline_str[0] = '\0';
    1192 
    11931072        current_time = get_time();
    11941073        time_taken = current_time - g_start_time;
     
    11971076        } else {
    11981077            if (g_current_progress > g_maximum_progress) {
    1199                 sprintf(tmp,
    1200                         "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",
    1201                         blurb1, blurb2, blurb3, g_current_progress,
    1202                         g_maximum_progress);
    1203                 log_msg(0, tmp);
     1078                log_msg(0, "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", blurb1, blurb2, blurb3, g_current_progress, g_maximum_progress);
    12041079                g_current_progress = g_maximum_progress;
    12051080            }
    1206             percentage =
    1207                 (int) ((g_current_progress * 100L) / g_maximum_progress);
     1081            percentage = (int) ((g_current_progress * 100L) / g_maximum_progress);
    12081082        }
    12091083        if (percentage < 1) {
     
    12141088        }
    12151089        if (g_current_progress) {
    1216             time_total_est =
    1217                 time_taken * (long) g_maximum_progress /
    1218                 (long) (g_current_progress);
     1090            time_total_est = time_taken * (long) g_maximum_progress / (long) g_current_progress;
    12191091            time_remaining = time_total_est - time_taken;
    12201092        } else {
     
    12221094        }
    12231095        g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
    1224         sprintf(timeline_str,
    1225                 "%2ld:%02ld taken               %2ld:%02ld remaining  ",
    1226                 (long) time_taken / 60, time_taken % 60, time_remaining / 60,
    1227                 time_remaining % 60);
    1228         sprintf(percentline_str, " %3d%% done                 %3d%% to go",
    1229                 percentage, 100 - percentage);
    1230 
    12311096        if (g_text_mode) {
    12321097            printf("---progress-form---1--- %s\n", blurb1);
     
    12441109                log_msg(2, "percentage = %d", percentage);
    12451110            }
    1246             mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
    1247                             (long) time_remaining / 60, (long) time_remaining % 60);
     1111            mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
    12481112            printf("---progress-form---4--- %s\n", taskprogress);
    12491113            paranoid_free(taskprogress);
    12501114        } else {
     1115            mr_asprintf(timeline_str, "%2ld:%02ld taken               %2ld:%02ld remaining  ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
     1116            mr_asprintf(percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
     1117
    12511118            center_string(blurb1, 54);
    12521119            center_string(blurb2, 54);
     
    12651132                newtLabelSetText(g_timeline, timeline_str);
    12661133            }
     1134            mr_free(timeline_str);
     1135
    12671136            if (g_percentline) {
    12681137                newtLabelSetText(g_percentline, percentline_str);
    12691138            }
     1139            mr_free(percentline_str);
     1140
    12701141            newtDrawForm(g_progressForm);
    12711142            newtRefresh();
    12721143        }
    1273         paranoid_free(percentline_str);
    1274         paranoid_free(timeline_str);
    1275         paranoid_free(tmp);
    1276     }
    1277 
    1278 
    1279 
    1280 
    1281 
    1282 
    1283 
    1284 
    1285 
    1286 
    1287 
    1288 
     1144    }
    12891145
    12901146
     
    12971153 * @return The backup type chosen, or @c none if the user chose "Exit to shell".
    12981154 */
    1299     t_bkptype which_backup_media_type(bool restoring) {
     1155t_bkptype which_backup_media_type(bool restoring) {
    13001156
    13011157        /*@ char ************************************************************ */
     
    13041160
    13051161        /*@ newt ************************************************************ */
    1306         char *title_sz;
    1307         char *minimsg_sz;
    1308         static t_bkptype possible_bkptypes[] =
    1309             { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
    1310         static char *possible_responses[] =
    1311             { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev",
    1312 "netfs", "iso", NULL };
    1313         char *outstr;
    1314         char *p;
     1162        char *title_sz = NULL;
     1163        char *minimsg_sz = NULL;
     1164        static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
     1165        static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL };
     1166        char *outstr = NULL;
    13151167        t_bkptype backup_type;
    13161168        int i;
     
    13271179        newtComponent myForm;
    13281180
    1329         title_sz = malloc(MAX_NEWT_COMMENT_LEN);
    1330         minimsg_sz = malloc(MAX_NEWT_COMMENT_LEN);
    1331         outstr = malloc(MAX_NEWT_COMMENT_LEN);
    13321181        if (g_text_mode) {
    13331182            for (backup_type = none; backup_type == none;) {
     
    13381187                }
    13391188                printf(")\n--> ");
    1340                 p = fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin);
    1341                 if (!p) {
    1342                     // FIXME
    1343                 }
    1344                 strip_spaces(outstr);
     1189                mr_getline(outstr, stdin);
     1190                mr_strip_spaces(outstr);
    13451191                for (i = 0; possible_responses[i]; i++) {
    13461192                    if (!strcmp(possible_responses[i], outstr)) {
     
    13481194                    }
    13491195                }
    1350             }
    1351             paranoid_free(title_sz);
    1352             paranoid_free(minimsg_sz);
    1353             paranoid_free(outstr);
     1196                mr_free(outstr);
     1197            }
    13541198            return (backup_type);
    13551199        }
    13561200        newtDrawRootText(18, 0, WELCOME_STRING);
    13571201        if (restoring) {
    1358             strcpy(title_sz,
    1359                    "Please choose the backup media from which you want to read data.");
    1360             strcpy(minimsg_sz, "Read from:");
    1361         } else {
    1362             strcpy(title_sz,
    1363                    "Please choose the backup media to which you want to archive data.");
    1364             strcpy(minimsg_sz, "Backup to:");
     1202            mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
     1203            mr_asprintf(minimsg_sz, "Read from:");
     1204        } else {
     1205            mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
     1206            mr_asprintf(minimsg_sz, "Backup to:");
    13651207        }
    13661208        newtPushHelpLine(title_sz);
    1367         //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
    13681209        newtCenteredWindow(34, 17, minimsg_sz);
    13691210        b1 = newtButton(1, 1, "CD-R disks ");
     
    13991240        }
    14001241        newtPopHelpLine();
    1401         paranoid_free(title_sz);
    1402         paranoid_free(minimsg_sz);
    1403         paranoid_free(outstr);
     1242        mr_free(title_sz);
     1243        mr_free(minimsg_sz);
    14041244        return (output);
    14051245    }
     
    14231263        newtComponent b2;
    14241264        newtComponent b3;
    1425         //newtComponent b4;
     1265        newtComponent b4;
    14261266        newtComponent b5;
    14271267        newtComponent b_res;
     
    14351275        b2 = newtButton(18, 1, "gzip");
    14361276        b3 = newtButton(4, 5, "lzo");
    1437         //b4 = newtButton(18, 5, "lzma");
     1277        b4 = newtButton(18, 5, "lzma");
    14381278        b5 = newtButton(4, 9, "         Exit        ");
    14391279        myForm = newtForm(NULL, NULL, 0);
     
    14481288        } else if (b_res == b3) {
    14491289            mr_asprintf(output, "%s", "lzo");
    1450         //} else if (b_res == b4) {
    1451             //mr_asprintf(output, "%s", "lzma");
     1290        } else if (b_res == b4) {
     1291            mr_asprintf(output, "%s", "lzma");
    14521292        }
    14531293        newtPopHelpLine();
     
    14611301 * @return The compression level (0-9) chosen, or -1 for "Exit".
    14621302 */
    1463     int
    1464      which_compression_level() {
     1303int which_compression_level() {
    14651304
    14661305        /*@ char ************************************************************ */
     
    14791318
    14801319        newtDrawRootText(18, 0, WELCOME_STRING);
    1481         newtPushHelpLine
    1482             ("   Please specify the level of compression that you want.");
    1483         //  newtOpenWindow (23, 3, 34, 13, "How much compression?");
     1320        newtPushHelpLine("   Please specify the level of compression that you want.");
    14841321        newtCenteredWindow(34, 13, "How much compression?");
    14851322        b1 = newtButton(4, 1, "Maximum (9)");
     
    15181355 * @param source_file The file containing a list of filenames to load into @p filelist.
    15191356 */
    1520     int load_filelist_into_array(struct s_filelist *filelist,
    1521                                  char *source_file) {
     1357int load_filelist_into_array(struct s_filelist *filelist, char *source_file) {
     1358
    15221359        int i;
    15231360        int j = 0;
    15241361        bool done;
    1525         char *tmp;
    1526         char *p;
     1362        char *tmp = NULL;
    15271363        char *tmp1 = NULL;
    15281364        FILE *fin, *fout;
     
    15431379        if (!(fout = fopen(tmp1, "a"))) {
    15441380            log_msg(2, "Can't write to %s", tmp1);
     1381            mr_free(tmp1);
    15451382            return(1);
    15461383            }
    15471384
    1548         malloc_string(tmp);
    15491385        log_msg(2, "Loading %s", source_file);
    1550         for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM;
    1551              filelist->entries++) {
    1552           god_i_hate_gotos:
     1386        for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
     1387            mr_free(tmp);
    15531388            if (feof(fin)) {
    15541389                break;
    15551390            }
    1556             p = fgets(tmp, MAX_NEWT_COMMENT_LEN, fin);
    1557             if (!p) {
    1558                 // FIXME
    1559             }
     1391            mr_getline(tmp, fin);
    15601392            i = (int) strlen(tmp);
    15611393            if (i < 2) {
    1562                 goto god_i_hate_gotos;
     1394                continue;
    15631395            }
    15641396            if (tmp[i - 1] < 32) {
     
    15661398            }
    15671399            if (i < 2) {
    1568                 goto god_i_hate_gotos;
     1400                continue;
    15691401            }
    15701402            if (!does_file_exist(tmp) && !feof(fin)) {
    15711403                j++;
    15721404                fprintf(fout, "%s\n", tmp);
    1573 
    1574                 goto god_i_hate_gotos;
    1575             }
    1576             filelist->el[filelist->entries].severity =
    1577                 severity_of_difference(tmp, NULL);
     1405                continue;
     1406            }
     1407            filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL);
    15781408            strcpy(filelist->el[filelist->entries].filename, tmp);
    15791409            if (feof(fin)) {
    15801410                break;
    15811411            }
    1582         }
     1412            filelist->entries++;
     1413        }
     1414        mr_free(tmp);
    15831415        paranoid_fclose(fin);
    15841416        paranoid_fclose(fout);
     
    15861418            log_to_screen("%d files listed in %s/changed.files have been deleted since backup was made\nand are referenced in %s", j, bkpinfo->tmpdir,tmp1);
    15871419        }
    1588         paranoid_free(tmp1);
     1420        mr_free(tmp1);
    15891421        if (filelist->entries >= ARBITRARY_MAXIMUM) {
    15901422            log_to_screen("Arbitrary limits suck, man!");
    1591             paranoid_free(tmp);
    15921423            return (1);
    15931424        }
     
    16171448            }
    16181449        }
    1619         paranoid_free(tmp);
    16201450        log_it("leaving");
    16211451        return (0);
    16221452    }
    1623 
    16241453
    16251454
     
    16301459 * @note The returned value points to static storage that will be overwritten with each call.
    16311460 */
    1632     char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
     1461char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    16331462        static char comment[100];
    16341463        char *tmp = NULL;
    16351464
    1636         log_it("entering");
     1465        log_msg(8, "entering");
    16371466        assert(flentry != NULL);
    16381467        if (flentry->severity == 0) {
     
    16481477        mr_strcat(tmp, flentry->filename);
    16491478        strncpy(comment, tmp, 99);
    1650         paranoid_free(tmp);
     1479        mr_free(tmp);
    16511480
    16521481        log_it("leaving");
    16531482        return (comment);
    16541483    }
    1655 
    1656 
    1657 
    16581484
    16591485
     
    16631489 * @param source_file The file containing a list of changed files.
    16641490 */
    1665     void popup_changelist_from_file(char *source_file) {
    1666         char *reason;
     1491void popup_changelist_from_file(char *source_file) {
     1492
     1493        char *reason = NULL;
    16671494        newtComponent myForm;
    16681495        newtComponent bClose;
     
    16851512
    16861513        /*@ buffers ********************************************************* */
    1687         char *tmp;
    1688         char *differ_sz;
     1514        char *tmp = NULL;
     1515        char *differ_sz = NULL;
    16891516
    16901517        struct s_filelist *filelist;
    1691         malloc_string(reason);
    1692         tmp = malloc(5000);
    1693         malloc_string(differ_sz);
    16941518        assert_string_is_neither_NULL_nor_zerolength(source_file);
    16951519        if (g_text_mode) {
    16961520            log_msg(2, "Text mode. Therefore, no popup list.");
    1697             goto free_to_go;
     1521            return;
    16981522        }
    16991523        log_msg(2, "Examining file %s", source_file);
     
    17021526        if (lng < 1) {
    17031527            log_msg(2, "No lines in file. Therefore, no popup list.");
    1704             paranoid_free(reason);
    1705             goto free_to_go;
     1528            return;
    17061529        } else if (lng >= ARBITRARY_MAXIMUM) {
    17071530            log_msg(2, "Too many files differ for me to list.");
    1708             goto free_to_go;
     1531            return;
    17091532        }
    17101533
     
    17151538
    17161539        if (load_filelist_into_array(filelist, source_file)) {
    1717             log_msg(2, "Can't open %s; therefore, cannot popup list",
    1718                     source_file);
    1719             paranoid_free(reason);
     1540            log_msg(2, "Can't open %s; therefore, cannot popup list", source_file);
    17201541            return;
    17211542        }
    1722         log_msg(2, "%d files loaded into filelist array",
    1723                 filelist->entries);
     1543        log_msg(2, "%d files loaded into filelist array", filelist->entries);
    17241544        for (i = 0; i < filelist->entries; i++) {
    17251545            keylist[i] = (void *) i;
     
    17301550                                   keylist[i]);
    17311551        }
    1732         sprintf(differ_sz,
    1733                 "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.",
    1734                 i);
     1552        mr_asprintf(differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
    17351553        newtPushHelpLine(differ_sz);
     1554        mr_free(differ_sz);
     1555
    17361556        bClose = newtCompactButton(10, 15, " Close  ");
    17371557        bSelect = newtCompactButton(30, 15, " Select ");
    1738         sprintf(tmp, "%-10s               %-20s", "Priority", "Filename");
     1558        mr_asprintf(tmp, "%-10s               %-20s", "Priority", "Filename");
    17391559        headerMsg = newtLabel(2, 1, tmp);
     1560        mr_free(tmp);
     1561
    17401562        newtOpenWindow(5, 4, 70, 16, "Non-matching files");
    17411563        myForm = newtForm(NULL, NULL, 0);
    1742         newtFormAddComponents(myForm, headerMsg, fileListbox, bClose,
    1743                               bSelect, NULL);
     1564        newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL);
     1565
    17441566        while (!finished) {
    17451567            b_res = newtRunForm(myForm);
     
    17561578                    currline = i;
    17571579                    if (filelist->entries > 0) {
    1758                         severity_of_difference(filelist->el[currline].
    1759                                                filename, reason);
    1760                         sprintf(tmp, "%s --- %s",
    1761                                 filelist->el[currline].filename, reason);
     1580                        malloc_string(reason);
     1581                        severity_of_difference(filelist->el[currline].  filename, &reason);
     1582                        mr_asprintf(tmp, "%s --- %s", filelist->el[currline].filename, reason);
     1583
    17621584                        popup_and_OK(tmp);
     1585                        mr_free(tmp);
     1586                        paranoid_free(reason);
    17631587                    }
    17641588                }
     
    17681592        newtPopWindow();
    17691593        newtPopHelpLine();
    1770       free_to_go:
    1771         paranoid_free(reason);
    1772         paranoid_free(tmp);
    1773         paranoid_free(differ_sz);
    17741594        return;
    17751595    }
Note: See TracChangeset for help on using the changeset viewer.