misc/memset.c
void* bytewise_memset(void* s, int c, size_t sz) {
    byte* p = (byte*)s;

    /* c should only be a byte's worth of information anyway, but let's mask out
     * everything else just in case.
     */
    byte x = c & 0xff;

    while (sz--)
        *p++ = x;
    return s;
}
/* Let's start off with a fairly naive implementation of memset. This sets
 * memory byte-by-byte. While not being particularly efficient and being
 * slightly braindead, it does have the advantage of being readily
 * understandable and reasonably straightforward to implement without making
 * mistakes.
 */
Let's start off with a fairly naive implementation of memset. This sets
memory byte-by-byte. While not being particularly efficient and being
slightly braindead, it does have the advantage of being readily
understandable and reasonably straightforward to implement without making
mistakes.
Let ' s start off with a fairly naive implementation of memset . This sets memory byte - by - byte . While not being particularly efficient and being slightly braindead it does have the advantage of being readily understandable and reasonably straightforward to implement without making mistakes .
void* bytewise_memset(void* s, int c, size_t sz) {
    byte* p = (byte*)s;
    byte x = c & 0xff;
    while (sz--)
        *p++ = x;
    return s;
}
void * bytewise_memset ( void * s , int c , size_t sz ) { byte * p = ( byte * ) s ; byte x = c & 0xff ; while ( sz -- ) * p ++ = x ; return s ; }
Let's start off with a fairly naive implementation of memset.
Let ' s start off with a fairly naive implementation of memset .
/* c should only be a byte's worth of information anyway, but let's mask out
     * everything else just in case.
     */