How to check whether all bytes in a memory block are zero

You could perhaps actually use memcmp without having to allocate a zero-valued array, like this:

static int memvcmp(void *memory, unsigned char val, unsigned int size)
{
    unsigned char *mm = (unsigned char*)memory;
    return (*mm == val) && memcmp(mm, mm + 1, size - 1) == 0;
}

The standard for memcmp does not say anything about overlapping memory regions.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)