mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 12:04:27 +01:00
mmap anonymous: configurable size
This commit is contained in:
18
userland/c/malloc_max.c
Normal file
18
userland/c/malloc_max.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#malloc-maximum-size */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
char *ptr = NULL;
|
||||
size_t size = 1;
|
||||
while (1) {
|
||||
printf("0x%zx\n", size);
|
||||
ptr = realloc(ptr, size);
|
||||
if (ptr == NULL) {
|
||||
break;
|
||||
} else {
|
||||
size <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user