misc/memset.c
int check_memset(void* f(), int unaligned) {
    char buffer[BUFFER_LEN];
    int i;
    char set;

    for (set = 0; (unsigned int)set <= 0xff; ++set) {
        f(buffer + unaligned, set, BUFFER_LEN - 2*unaligned);
        for (i = unaligned; i < BUFFER_LEN - 2*unaligned; ++i)
            if (buffer[i] != set)
                return i + 1;
    }

    return 0;
}
/* This function does some very basic checking of your memset function. If you
 * really want to comprehensively test your function you should check the
 * regions either side of the memory you are setting to make sure your function
 * is actually obeying the limits passed to it.
 *
 * Note, the argument unaligned determines whether we pass an unaligned pointer
 * and size or not. Only certain of the above implementations will pass this
 * test.
 */
This function does some very basic checking of your memset function. If you
really want to comprehensively test your function you should check the
regions either side of the memory you are setting to make sure your function
is actually obeying the limits passed to it.

Note, the argument unaligned determines whether we pass an unaligned pointer
and size or not. Only certain of the above implementations will pass this
test.
This function does some very basic checking of your memset function . If you really want to comprehensively test your function you should check the regions either side of the memory you are setting to make sure your function is actually obeying the limits passed to it . Note the argument unaligned determines whether we pass an unaligned pointer and size or not . Only certain of the above implementations will pass this test .
int check_memset(void* f(), int unaligned) {
    char buffer[BUFFER_LEN];
    int i;
    char set;
    for (set = 0; (unsigned int)set <= 0xff; ++set) {
        f(buffer + unaligned, set, BUFFER_LEN - 2*unaligned);
        for (i = unaligned; i < BUFFER_LEN - 2*unaligned; ++i)
            if (buffer[i] != set)
                return i + 1;
    }
    return 0;
}
int check_memset ( void * f ( ) , int unaligned ) { char buffer [ BUFFER_LEN ] ; int i ; char set ; for ( set = 0 ; ( unsigned int ) set <= 0xff ; ++ set ) { f ( buffer + unaligned , set , BUFFER_LEN - 2 * unaligned ) ; for ( i = unaligned ; i < BUFFER_LEN - 2 * unaligned ; ++ i ) if ( buffer [ i ] != set ) return i + 1 ; } return 0 ; }
This function does some very basic checking of your memset function.
This function does some very basic checking of your memset function .