36 lines
615 B
C
36 lines
615 B
C
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
int strcmp(const char *a, const char *b)
|
|
{
|
|
while (*a != '\0' && *b != '\0') {
|
|
if (*a != *b)
|
|
return (*a > *b) - (*a < *b);
|
|
a++, b++;
|
|
}
|
|
if (*a == '\0' && *b == '\0')
|
|
return 0;
|
|
|
|
if (*a == '\0')
|
|
return -1;
|
|
return 1;
|
|
}
|
|
|
|
void *memcpy(void *dest, const void *src, size_t count)
|
|
{
|
|
void *ret = dest;
|
|
for (const byte_t *p = src; count > 0; --count, ++p, ++dest)
|
|
*(byte_t *)dest = *p;
|
|
|
|
return ret;
|
|
}
|
|
|
|
void *memzero(void *start, void *end)
|
|
{
|
|
void *ret = start;
|
|
for (byte_t *p = start; p < (byte_t *)end; ++p)
|
|
*p = 0;
|
|
|
|
return ret;
|
|
}
|