feat(sys): add malloc
This commit is contained in:
15
app/nolibc.c
15
app/nolibc.c
@@ -1,6 +1,19 @@
|
||||
#include <c-libs/sys/memory.h>
|
||||
#include <c-libs/sys/syscall.h>
|
||||
|
||||
void strcpy(char *dst, const char *src) {
|
||||
int ix = 0;
|
||||
do {
|
||||
dst[ix] = src[ix];
|
||||
} while (src[ix++]);
|
||||
}
|
||||
|
||||
int main() {
|
||||
write(0, "Hello World!\n", 13);
|
||||
char *str = malloc(14);
|
||||
strcpy(str, "Hello World!\n");
|
||||
|
||||
write(0, str, 13);
|
||||
|
||||
munmap(str, 14);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user