2020-06-17 16:39:50 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-04-06 20:49:52 -04:00
|
|
|
#include <malloc.h>
|
|
|
|
|
2020-06-17 16:39:50 -04:00
|
|
|
#include "test_util.h"
|
|
|
|
|
2020-09-18 11:38:06 -04:00
|
|
|
static void print_mallinfo(void) {
|
2021-12-23 12:27:18 -05:00
|
|
|
#if defined(__GLIBC__) || defined(__ANDROID__)
|
2019-04-06 20:49:52 -04:00
|
|
|
struct mallinfo info = mallinfo();
|
2020-09-18 11:38:06 -04:00
|
|
|
printf("mallinfo:\n");
|
2020-11-10 14:14:08 -05:00
|
|
|
printf("arena: %zu\n", (size_t)info.arena);
|
|
|
|
printf("ordblks: %zu\n", (size_t)info.ordblks);
|
|
|
|
printf("smblks: %zu\n", (size_t)info.smblks);
|
|
|
|
printf("hblks: %zu\n", (size_t)info.hblks);
|
|
|
|
printf("hblkhd: %zu\n", (size_t)info.hblkhd);
|
|
|
|
printf("usmblks: %zu\n", (size_t)info.usmblks);
|
|
|
|
printf("fsmblks: %zu\n", (size_t)info.fsmblks);
|
|
|
|
printf("uordblks: %zu\n", (size_t)info.uordblks);
|
|
|
|
printf("fordblks: %zu\n", (size_t)info.fordblks);
|
|
|
|
printf("keepcost: %zu\n", (size_t)info.keepcost);
|
2021-12-23 12:27:18 -05:00
|
|
|
#endif
|
2019-04-06 20:49:52 -04:00
|
|
|
}
|
2020-09-18 11:38:06 -04:00
|
|
|
|
|
|
|
OPTNONE int main(void) {
|
|
|
|
void *a[4];
|
|
|
|
|
|
|
|
a[0] = malloc(1024 * 1024 * 1024);
|
|
|
|
a[1] = malloc(16);
|
|
|
|
a[2] = malloc(32);
|
|
|
|
a[3] = malloc(64);
|
|
|
|
|
|
|
|
print_mallinfo();
|
|
|
|
|
|
|
|
free(a[0]);
|
|
|
|
free(a[1]);
|
|
|
|
free(a[2]);
|
|
|
|
free(a[3]);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
print_mallinfo();
|
|
|
|
}
|