Changeset 1215 in MondoRescue


Ignore:
Timestamp:
Feb 27, 2007, 7:07:36 AM (17 years ago)
Author:
Bruno Cornec
Message:

Improve mr_strip_space where nothing should be done (valgrind report)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/lib/mr_str.c

    r1205 r1215  
    123123 */
    124124void mr_strip_spaces(char *in_out) {
    125     int i;
    126     int j;
     125    int i = 0;
     126    int j = 0;
    127127    size_t length;
    128128
     
    134134    /* Skip initial spaces and special chars */
    135135    for (i = 0; in_out[i] <= ' ' && i < (int)length ; i++);
    136     /* Shift the string to the begining */
    137     for (j = 0; i < (int)length ; i++, j++) {
    138         in_out[j] = in_out[i];
     136    /* Shift the string to the begining if needed */
     137    if (i != 0) {
     138        for (j = 0; i < (int)length ; i++, j++) {
     139            in_out[j] = in_out[i];
     140        }
     141        /* Erase the end of the string if needed */
     142        j++;
     143        in_out[j] = '\0';
    139144    }
    140     /* Erase the end of the string */
    141     j++;
    142     in_out[j] = '\0';
    143145
    144146    /* Skip final spaces and special chars */
Note: See TracChangeset for help on using the changeset viewer.