forked from mfleming/efilinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdlib.h
58 lines (44 loc) · 872 Bytes
/
stdlib.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef __STDLIB_H__
#define __STDLIB_H__
extern void *malloc(UINTN size);
extern void free(void *buf);
extern EFI_STATUS emalloc(UINTN, UINTN, EFI_PHYSICAL_ADDRESS *);
extern void efree(EFI_PHYSICAL_ADDRESS, UINTN);
static inline void memset(char *dst, char ch, UINTN size)
{
int i;
for (i = 0; i < size; i++)
dst[i] = ch;
}
static inline void memcpy(char *dst, char *src, UINTN size)
{
int i;
for (i = 0; i < size; i++)
*dst++ = *src++;
}
static inline int strlen(char *str)
{
int len;
len = 0;
while (*str++)
len++;
return len;
}
static inline char *strstr(char *haystack, char *needle)
{
char *p;
char *word = NULL;
int len = strlen(needle);
if (!len)
return NULL;
p = haystack;
while (*p) {
word = p;
if (!strncmpa((CHAR8 *)p, (CHAR8 *)needle, len))
break;
p++;
word = NULL;
}
return word;
}
#endif /* __STDLIB_H__ */