Implemented malloc, abort, exit

This commit is contained in:
Max Wash
2020-04-17 11:24:05 +01:00
parent bf4e733688
commit 076ace9956
8 changed files with 6317 additions and 4 deletions

28
tests/memory.c Normal file
View File

@@ -0,0 +1,28 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
char buf[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
};
char *buf2 = malloc(sizeof(buf));
memcpy(buf2, buf, sizeof(buf));
for (size_t i = 0; i < sizeof(buf2); i++) {
if (buf[i] != buf2[i]) {
printf("buf[%zu] != buf2[%zu] !!\n", i, i);
return -1;
}
}
printf("copy ok.\n");
free(buf2);
return 0;
}