Consider this:
Code:
int i;
char *v[MAXELEMENTS];

for (i = 0; i < MAXELEMENTS; i++) {
    if ((v[i] = malloc(blablabla)) == NULL) {
        printf("error\n");
        while (--i >= 0)
            free(v[i]);
        break;
    }

    do something with v[i]...
}
Is the part in red necessary if I exit the program right after displaying the error message?