#include /* Fill a region of memory with specified byte */ void * memset(void *dest, int byte, size_t len) { unsigned char *a = dest; if (len > 0) { while (len-- > 0) *a++ = byte; } return dest; } /* Copy one region of memory to another */ int memcmp(void *s1, void *s2, size_t n) { unsigned char *a = (unsigned char *) s1, *b = (unsigned char *) s2; while (n-- > 0) if (*a++ != *b++) return a[-1] - b[-1]; return 0; } /* Copy one region of memory to another */ void * memcpy(void *dest, void *src, size_t n) { unsigned char *a = (unsigned char *) dest, *b = (unsigned char *) src; while (n-- > 0) *a++ = *b++; return dest; }