Browse Source

* Fixed memcmp() prototype and implementation.

tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
fa2ca5f46e
2 changed files with 8 additions and 5 deletions
  1. +6
    -4
      kernel/kernel.c
  2. +2
    -1
      kernel/kernel.h

+ 6
- 4
kernel/kernel.c View File

@@ -175,14 +175,16 @@ int strcasecmp(const char *s1, const char *s2)
return (int)UPPER(*s1) - (int)UPPER(*s2);
}

int memcmp(const char *s1, const char *s2, size_t n)
int memcmp(const void *_s1, const void *_s2, size_t n)
{
unsigned char const *s1 = _s1, *s2 = _s2;

while(n--)
{
if(*s1 != *s2)
return *s1 - *s2;
*s1++;
*s2++;
return (int)*s1 - (int)*s2;
s1++;
s2++;
}
return 0;
}


+ 2
- 1
kernel/kernel.h View File

@@ -85,7 +85,8 @@ void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
size_t strlen(const char *s);
int strcasecmp(const char *s1, const char *s2);
int memcmp(const char *s1, const char *s2, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);

/* stdarg.h functions */
typedef void * va_list;
#define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))


Loading…
Cancel
Save