cmdriver/src/CMDriver.cxx
//---------------------------------------------------------------------------------------------
// Adds to a set of results new result at the end.
//   - Reallocate memory.
//   - Adds new line if necessary.
//---------------------------------------------------------------------------------------------
Adds to a set of results new result at the end.
Reallocate memory.
Adds new line if necessary.
Adds to a set of results new result at the end . Reallocate memory . Adds new line if necessary .
static char* combineResults(char *resultsSet, char *result) {
    if(result == NULL || result[0] == 0) {
        return resultsSet;
    }
    int oldSetLen = (resultsSet != NULL) ? strlen(resultsSet) : 0;
    int newSetLen = strlen(result) + oldSetLen + 3;
    char *newResultsSet = new char [newSetLen];
    newResultsSet[0] = 0;
    if(oldSetLen > 0) {
        strcat(newResultsSet, resultsSet);
        if(resultsSet[oldSetLen - 1] != '\n') {
            strcat(newResultsSet, "\n");
        }
    }
    strcat(newResultsSet, result);
    delete [] resultsSet;
    return newResultsSet;
}
static char * combineResults ( char * resultsSet , char * result ) { if ( result == NULL || result [ 0 ] == 0 ) { return resultsSet ; } int oldSetLen = ( resultsSet != NULL ) ? strlen ( resultsSet ) : 0 ; int newSetLen = strlen ( result ) + oldSetLen + 3 ; char * newResultsSet = new char [ newSetLen ] ; newResultsSet [ 0 ] = 0 ; if ( oldSetLen > 0 ) { strcat ( newResultsSet , resultsSet ) ; if ( resultsSet [ oldSetLen - 1 ] != ' \n ' ) { strcat ( newResultsSet , " \n " ) ; } } strcat ( newResultsSet , result ) ; delete [ ] resultsSet ; return newResultsSet ; }
Adds to a set of results new result at the end.
Adds to a set of results new result at the end .
// M.b. nothing to add // Calculate new length of the set of results // New buffer for the set // Copy the old set to the new buffer // Add divider if necessary // Add new result // Delete the old set