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

Useless code

Name: Anonymous 2008-11-20 4:06


bool useless(int32_t val, char *b, size_t bl, char **nl)
{
    uint32_t c,i,msk;
    bool ret;

    c = 0;
    msk = 1000000000;
    if (val == 0) {
        b[c++] = '0';
        ret = true;
    } else {
        if (val < 0) {
            b[c++] = '-';
            val *= -1;
        }
        while (get_cypher(val, msk) == 0 && msk > 0) {
            msk /= 10;
        }
        bl--;
        while (c < bl && msk > 0) {
            b[c++] = '0' + get_cypher(val, msk);
            msk /= 10;
        }
        ret = (msk == 0);
    }
    *nl = b + (c <= bl ? c : bl);
    *nl[0] = 0;
    return ret;
}

Name: Anonymous 2008-11-20 5:03

>>6
most of the time when people use snprintf, they really want to use asprintf instead... too bad it's not in the C standard, even though it is supported by just about every widely used libc.

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