#include "vga.h"
void *
-memset (void *dst_, int value, size_t cnt)
+memset (void *dst_, int value, size_t size)
{
unsigned char *dst = dst_;
+
+ ASSERT (dst != NULL || size == 0);
- while (cnt-- > 0)
+ while (size-- > 0)
*dst++ = value;
return dst_;
}
void *
-memcpy (void *dst_, const void *src_, size_t cnt)
+memcpy (void *dst_, const void *src_, size_t size)
{
unsigned char *dst = dst_;
const unsigned char *src = src_;
- while (cnt-- > 0)
+ ASSERT (dst != NULL || size == 0);
+ ASSERT (src != NULL || size == 0);
+
+ while (size-- > 0)
*dst++ = *src++;
return dst_;
}
void *
-memmove (void *dst_, const void *src_, size_t cnt)
+memmove (void *dst_, const void *src_, size_t size)
{
unsigned char *dst = dst_;
const unsigned char *src = src_;
+ ASSERT (dst != NULL || size == 0);
+ ASSERT (src != NULL || size == 0);
+
if (dst < src)
{
- while (cnt-- > 0)
+ while (size-- > 0)
*dst++ = *src++;
}
else
{
- dst += cnt;
- src += cnt;
- while (cnt-- > 0)
+ dst += size;
+ src += size;
+ while (size-- > 0)
*--dst = *--src;
}
const unsigned char *block = block_;
unsigned char ch = ch_;
+ ASSERT (block != NULL || size == 0);
+
for (; size-- > 0; block++)
if (*block == ch)
return (void *) block;
const unsigned char *a = a_;
const unsigned char *b = b_;
+ ASSERT (a != NULL || size == 0);
+ ASSERT (b != NULL || size == 0);
+
for (; size-- > 0; a++, b++)
if (*a != *b)
return *a > *b ? +1 : -1;
size_t
strlcpy (char *dst, const char *src, size_t size)
{
- size_t src_len = strlen (src);
+ size_t src_len;
+
+ ASSERT (dst != NULL);
+ ASSERT (src != NULL);
+
+ src_len = strlen (src);
if (size > 0)
{
size_t dst_len_max = size - 1;
{
const char *p;
+ ASSERT (string != NULL);
+
for (p = string; *p != '\0'; p++)
continue;
return p - string;
{
char c = c_;
+ ASSERT (string != NULL);
+
for (;;)
if (*string == c)
return (char *) string;
else if (*string == '\0')
return NULL;
- else string++;
+ else
+ string++;
+}
+
+int
+strcmp (const char *a_, const char *b_)
+{
+ const unsigned char *a = (const unsigned char *) a_;
+ const unsigned char *b = (const unsigned char *) b_;
+
+ ASSERT (a != NULL);
+ ASSERT (b != NULL);
+
+ while (*a != '\0' && *a == *b)
+ {
+ a++;
+ b++;
+ }
+
+ return *a < *b ? -1 : *a > *b;
}
\f
static void
void (*output) (char, void *), void *aux);
static void
-vprintk_helper (char ch, void *aux __attribute__ ((unused)))
+vprintk_helper (char ch, void *aux UNUSED)
{
vga_putc (ch);
serial_outb (ch);