Ignore:
Timestamp:
Aug 18, 2009, 5:28:18 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
File:
1 edited

Legend:

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

    r2331 r2334  
    345345            log_msg(0, "-------FATAL ERROR---------");
    346346            log_msg(0, error_string);
    347             newtFinished();
    348347        }
    349348
     
    395394        }
    396395        if (!g_text_mode) {
    397             if (does_file_exist("/THIS-IS-A-RAMDISK")) {
    398                 log_msg(1, "Calling newtFinished()");
    399                 newtFinished();
    400             } else {
    401                 log_msg(1, "Calling newtSuspend()");
    402                 newtSuspend();
    403             }
     396            log_msg(1, "Calling newtFinished()");
     397            newtFinished();
    404398        }
    405399        printf("Execution run ended; result=%d\n", signal);
     
    444438
    445439        /*@ buffers ********************************************************** */
    446         char *command;
    447         char *tmp;
     440        char *command = NULL;
     441        char *tmp = NULL;
    448442
    449443        /*@ pointers ********************************************************* */
     
    453447        int i = 0;
    454448
    455         malloc_string(command);
    456         malloc_string(tmp);
    457449        assert_string_is_neither_NULL_nor_zerolength(filename);
    458450        assert(grep_for_me != NULL);
    459451
    460452        if (!does_file_exist(filename)) {
    461             paranoid_free(command);
    462             paranoid_free(tmp);
    463453            return;
    464454        }
    465455        if (grep_for_me[0] != '\0') {
    466             sprintf(command, "grep '%s' %s | tail -n%d",
    467                     grep_for_me, filename, g_noof_log_lines);
    468         } else {
    469             sprintf(command, "tail -n%d %s", g_noof_log_lines,
    470                     filename);
     456            mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
     457        } else {
     458            mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
    471459        }
    472460        fin = popen(command, "r");
     
    483471                    */
    484472                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    485                         strcpy(tmp, err_log_lines[i] + 6);
     473                        mr_asprintf(tmp, "%s", err_log_lines[i] + 6);
    486474                        strcpy(err_log_lines[i], tmp);
     475                        mr_free(tmp);
    487476                    }
    488477                    if (feof(fin)) {
     
    493482            paranoid_pclose(fin);
    494483        }
     484        mr_free(command);
    495485        refresh_log_screen();
    496         paranoid_free(command);
    497         paranoid_free(tmp);
    498486    }
    499487
     
    584572
    585573        /*@ buffers ********************************************************* */
    586         char *title;
    587         char *tmp;
     574        char *title = NULL;
     575        char *tmp = NULL;
    588576
    589577        /*@ initialize ****************************************************** */
    590578        g_isoform_old_progress = -1;
    591579        g_mysterious_dot_counter = 0;
    592         malloc_string(title);
     580
     581        assert(ttl != NULL);
    593582        malloc_string(tmp);
    594 
    595         assert(ttl != NULL);
    596         strcpy(title, ttl);
     583        mr_asprintf(title, "%s", ttl);
    597584        strcpy(g_isoform_header_str, title);
    598585        if (g_text_mode) {
     
    620607        }
    621608        update_evalcall_form(0);
     609        mr_free(title);
    622610        paranoid_free(tmp);
    623         paranoid_free(title);
    624611    }
    625612
     
    641628        /*@ buffers ********************************************************* */
    642629        char *b1c;
    643         char *blurb1;
    644         char *blurb2;
    645         char *blurb3;
     630        char *blurb1 = NULL;
     631        char *blurb2 = NULL;
     632        char *blurb3 = NULL;
    646633
    647634        /*@ initialize ****************************************************** */
    648635        g_mysterious_dot_counter = 0;
    649636
    650         malloc_string(b1c);
    651637        malloc_string(blurb1);
    652638        malloc_string(blurb2);
    653639        malloc_string(blurb3);
     640        malloc_string(b1c);
    654641
    655642        assert(title != NULL);
     
    658645        assert(b3 != NULL);
    659646
    660         strcpy(blurb1, b1);
    661         strcpy(blurb2, b2);
    662         strcpy(blurb3, b3);
     647        strcpy(blurb1,  b1);
     648        strcpy(blurb2,  b2);
     649        strcpy(blurb3,  b3);
    663650        strcpy(b1c, b1);
    664651        center_string(b1c, 80);
     
    695682        update_progress_form_full(blurb1, blurb2, blurb3);
    696683        paranoid_free(b1c);
    697         paranoid_free(blurb1);
    698         paranoid_free(blurb2);
    699         paranoid_free(blurb3);
     684        mr_free(blurb1);
     685        mr_free(blurb2);
     686        mr_free(blurb3);
    700687    }
    701688
     
    11761163
    11771164        /*@ newt ************************************************************ */
    1178         char *title_sz;
    1179         char *minimsg_sz;
     1165        char *title_sz = NULL;
     1166        char *minimsg_sz = NULL;
    11801167        static t_bkptype possible_bkptypes[] =
    11811168            { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso };
     
    11981185        newtComponent myForm;
    11991186
    1200         title_sz = malloc(MAX_NEWT_COMMENT_LEN);
    1201         minimsg_sz = malloc(MAX_NEWT_COMMENT_LEN);
    12021187        outstr = malloc(MAX_NEWT_COMMENT_LEN);
    12031188        if (g_text_mode) {
     
    12171202                }
    12181203            }
    1219             paranoid_free(title_sz);
    1220             paranoid_free(minimsg_sz);
    12211204            paranoid_free(outstr);
    12221205            return (backup_type);
     
    12241207        newtDrawRootText(18, 0, WELCOME_STRING);
    12251208        if (restoring) {
    1226             strcpy(title_sz,
    1227                    "Please choose the backup media from which you want to read data.");
    1228             strcpy(minimsg_sz, "Read from:");
    1229         } else {
    1230             strcpy(title_sz,
    1231                    "Please choose the backup media to which you want to archive data.");
    1232             strcpy(minimsg_sz, "Backup to:");
     1209            mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
     1210            mr_asprintf(minimsg_sz, "Read from:");
     1211        } else {
     1212            mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
     1213            mr_asprintf(minimsg_sz, "Backup to:");
    12331214        }
    12341215        newtPushHelpLine(title_sz);
     
    12661247        }
    12671248        newtPopHelpLine();
    1268         paranoid_free(title_sz);
    1269         paranoid_free(minimsg_sz);
     1249        mr_free(title_sz);
     1250        mr_free(minimsg_sz);
    12701251        paranoid_free(outstr);
    12711252        return (output);
Note: See TracChangeset for help on using the changeset viewer.