summaryrefslogtreecommitdiffstats
path: root/src/lib/string.c
blob: fb4d435aeeba907f0f5f10fec0c75d05321f9525 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <string.h>

void* memset(void* s, int c, size_t n)
{
    char* _s = s;
    while(n)
    {
	*_s = c;
	_s++; n--;
    }
}

int strcmp(const char* a, const char* b)
{
    while((*a != '\0') && (*b != '\0'))
    {
	if (*a == *b)
	{
	    a++; b++;
	}
	else
	{
	    return (*a > *b) ? 1 : -1;
	}
    }
    if (*a == *b)
	return 0;
    if (*a == '\0')
	return -1;
    else
	return 1;
}
OpenPOWER on IntegriCloud