Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Var Args are funky

Name: Anonymous 2007-05-21 0:19 ID:vdiiFf1F

When I did a return from va_arg(args, void *), it always seems to return null even though there are more arguments remaining. In this case, the arg list is filled with vars that need to be free'd prior to exiting the program. Anyone know why such an unsightly approach is needed?

int cp_error(const char *msg, int varc, ...) {
    int varg = 0;
    va_list args;

    if (varc > 0) {
        varg = 1;
        va_start(args, msg);
    }

    while (--varc >= 0) {
        va_arg(args, void *);
        free( (void *) *((char **) args) );
    }

    if (varg) {
        va_end(args);
    }

    fprintf(stdout, "%s\n", msg);

    return 0;
}

Name: Anonymous 2007-05-21 4:49 ID:vdiiFf1F

>>8
Maybe you have trouble to read, but I tried the approach you mentioned and it failed because you are WRONG.

And yes, I've read many manuals, including K&R. So please do us a favor and stick to the topic answering the question about why this is necessary in a microsoft compiler or STFU if you don't know.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List