summaryrefslogtreecommitdiff
path: root/memeat.c
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-10-08 00:23:14 +0100
committerAki <please@ignore.pl>2021-10-08 00:23:14 +0100
commiteb1e38da5b2d6f41b705bd224662b8d1725bc1b1 (patch)
tree6ce4f27b4570fa8e2a7dd2e8f8e4acafd23b2046 /memeat.c
downloadmemeat-eb1e38da5b2d6f41b705bd224662b8d1725bc1b1.zip
memeat-eb1e38da5b2d6f41b705bd224662b8d1725bc1b1.tar.gz
memeat-eb1e38da5b2d6f41b705bd224662b8d1725bc1b1.tar.bz2
Implemented a monsterHEADmaster
Diffstat (limited to 'memeat.c')
-rw-r--r--memeat.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/memeat.c b/memeat.c
new file mode 100644
index 0000000..dc5ee7a
--- /dev/null
+++ b/memeat.c
@@ -0,0 +1,24 @@
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static const int MEBIBYTE = 1024 * 1024;
+
+
+int
+main(int argc, char* argv[])
+{
+ const int max = argc > 1 ? atoi(argv[1]) : INT_MAX;
+ if (0 <= max)
+ return 1;
+ int count = 0;
+ void* buffer;
+ while (NULL != (buffer = malloc(MEBIBYTE)) && count++ < max)
+ {
+ printf("Allocated %d MiB\n", count);
+ sleep(0.5);
+ }
+}