mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-30 08:48:25 +04:00
edit memory_arena test.c
This commit is contained in:
parent
13072246fa
commit
c6c5d3cf46
@ -8,28 +8,26 @@
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
Arena arena = ArenaInit(1024 * 1024);
|
Arena arena = ArenaInit(1024 * 1024 * 1024);
|
||||||
|
|
||||||
char* str1 = ArenaAllocAligned(&arena, 5, sizeof(char));
|
char* str1 = ArenaAllocAligned(&arena, 5, sizeof(char));
|
||||||
strcpy(str1, "Hell");
|
strcpy(str1, "Hell");
|
||||||
printf("%s\n", str1);
|
printf("%s\n", str1);
|
||||||
|
|
||||||
|
|
||||||
int* int2 = ArenaAllocAligned(&arena, 2 * sizeof(int), sizeof(int));
|
int* int2 = ArenaAllocAligned(&arena, 2 * sizeof(int), sizeof(int));
|
||||||
int2[0] = 123;
|
int2[0] = 123;
|
||||||
int2[1] = 789;
|
int2[1] = 789;
|
||||||
printf("%d %d\n\n", int2[0], int2[1]);
|
printf("%d %d\n\n", int2[0], int2[1]);
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
printf("%d) %d\n", i, *((char*)(arena.buffer) + i));
|
printf("%2d) %d\n", i, *((char*)(arena.buffer) + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scanf("%s", str1)) {
|
||||||
|
ArenaDestroy(&arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanf("%s", str1);
|
scanf("%s", str1);
|
||||||
|
|
||||||
/*char* str3 = ArenaAllocAligned(&arena, 8, sizeof(char));
|
|
||||||
strcpy(str3, "ByeBye!!");
|
|
||||||
printf("%s", str3);*/
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user