Changeset 2355 in MondoRescue


Ignore:
Timestamp:
Aug 29, 2009, 12:56:50 AM (15 years ago)
Author:
Bruno Cornec
Message:

Remove function spread_flaws_across_three_lines and expand it at the single place where it was useful, and fix memory allocation issues in it.

Location:
branches/2.2.9/mondo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-string-EXT.h

    r2350 r2355  
    2121                         char *s);
    2222extern int special_dot_char(int i);
    23 extern void spread_flaws_across_three_lines(char *flaws_str,
    24                                             char *flaws_str_A,
    25                                             char *flaws_str_B,
    26                                             char *flaws_str_C);
    2723extern int strcmp_inc_numbers(char *stringA, char *stringB);
    2824extern char *strip_afio_output_line(char *input);
  • branches/2.2.9/mondo/src/common/libmondo-string.c

    r2350 r2355  
    598598    return ('.');
    599599}
    600 
    601 
    602 
    603 
    604 /**
    605  * Wrap @p flaws_str across three lines. The first two are no more than 74 characters wide.
    606  * @param flaws_str The original string to split.
    607  * @param flaws_str_A Where to put the first 74-or-less characters.
    608  * @param flaws_str_B Where to put the second 74-or-less characters.
    609  * @param flaws_str_C Where to put the rest.
    610  */
    611 void
    612 spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    613                                 char *flaws_str_B, char *flaws_str_C)
    614 {
    615 
    616     /*@ int ************************************************************* */
    617     int i = 0;
    618 
    619     /*@ initialize ****************************************************** */
    620     assert(flaws_str != NULL);
    621 
    622     if (strlen(flaws_str) > 0) {
    623         mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
    624     }
    625     if (strlen(flaws_str_A) >= 74) {
    626         for (i = 74; flaws_str_A[i] != ' '; i--);
    627         mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
    628         flaws_str_A[i] = '\0';
    629     }
    630     if (strlen(flaws_str_B) >= 74) {
    631         for (i = 74; flaws_str_B[i] != ' '; i--);
    632         mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
    633         flaws_str_B[i] = '\0';
    634     }
    635 }
    636 
    637600
    638601
  • branches/2.2.9/mondo/src/common/libmondo-string.h

    r2350 r2355  
    1717char *slice_fname(long bigfileno, long sliceno, char *path, char *s);
    1818int special_dot_char(int i);
    19 void spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    20                                      char *flaws_str_B, char *flaws_str_C);
    2119int strcmp_inc_numbers(char *stringA, char *stringB);
    2220char *strip_afio_output_line(char *input);
  • branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.c

    r2350 r2355  
    19761976    while (!finished) {
    19771977        flaws_str = evaluate_mountlist(mountlist, &res);
    1978         spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C);
    1979 
     1978        if (strlen(flaws_str) > 0) {
     1979            mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
     1980        } else {
     1981            mr_asprintf(&flaws_str_A, "");
     1982        }
     1983        if (strlen(flaws_str_A) >= 74) {
     1984            for (i = 74; flaws_str_A[i] != ' '; i--);
     1985            mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
     1986            flaws_str_A[i] = '\0';
     1987        } else {
     1988            mr_asprintf(&flaws_str_B, "");
     1989        }
     1990        if (strlen(flaws_str_B) >= 74) {
     1991            for (i = 74; flaws_str_B[i] != ' '; i--);
     1992            mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
     1993            flaws_str_B[i] = '\0';
     1994        } else {
     1995            mr_asprintf(&flaws_str_C, "");
     1996        }
    19801997        mr_free(flaws_str);
    19811998
  • branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.h

    r2350 r2355  
    180180void setup_newt_stuff(void);
    181181long size_of_specific_device(struct mountlist_itself *, char *);
    182 void spread_flaws_across_three_lines(char *, char *, char *, char *);
    183182char *turn_raid_level_number_to_string(int);
    184183void update_evalcall_form(int);
Note: See TracChangeset for help on using the changeset viewer.