12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include <libc/unistd.h>
- #include <libc/stdio.h>
- #include <libc/fcntl.h>
- #include <libc/stdlib.h>
- int main()
- {
- char string[] = "333.txt";
- uint8_t buf[128] = {0};
- char tips_str[] = "The first application 'init.bin' started successfully!\n";
- put_string(tips_str, COLOR_GREEN, COLOR_BLACK);
- printf("test printf: %s size: %d\n", string, sizeof(string));
-
- void *ptr[256] = {0};
- for (int k = 0; k < 2; ++k)
- {
- printf("try to malloc 256*16K=4MB\n");
- uint64_t js = 0;
- for (int i = 0; i < 256; ++i)
- {
- ptr[i] = malloc(4096 * 4);
- js += *(uint64_t *)((uint64_t)(ptr[i]) - sizeof(uint64_t));
- if (*(uint64_t *)((uint64_t)(ptr[i]) - sizeof(uint64_t)) > 0x4008)
- printf("[%d] start_addr = %#018lx, len = %#010lx\n", (uint64_t)(ptr[i]) - 8, *(uint64_t *)((uint64_t)(ptr[i]) - sizeof(uint64_t)));
- }
-
-
-
-
- printf("alloc done. total used: %lld bytes\n", js);
- printf("try to free...\n");
- for (int i = 0; i < 256; ++i)
- {
- free(ptr[i]);
- }
- printf("free done!\n");
- }
-
-
- while (1)
- ;
- }
|