assignment 4-1 epic opfuscated
authorMart Lubbers <mart@martlubbers.net>
Mon, 2 Mar 2015 08:32:13 +0000 (09:32 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 2 Mar 2015 08:32:13 +0000 (09:32 +0100)
ass4/assignment4.pdf [new file with mode: 0644]
ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1.c [new file with mode: 0644]
ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1b [new file with mode: 0644]

diff --git a/ass4/assignment4.pdf b/ass4/assignment4.pdf
new file mode 100644 (file)
index 0000000..e8b1b64
Binary files /dev/null and b/ass4/assignment4.pdf differ
diff --git a/ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1.c b/ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1.c
new file mode 100644 (file)
index 0000000..b361d09
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(void)
+{
+       size_t block = 0;
+       char *b, d = 1;
+       for(size_t i = 1 << 31; i >= 1; i /= 2, free(b))
+               d = (b = malloc(block += d * i)) == NULL ? -1 : 1;
+       printf("One malloc can allocate at most %zu bytes\n", block);
+}
diff --git a/ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1b b/ass4/mart/sws1-assignment4-s4109503-s4202015/exercise1b
new file mode 100644 (file)
index 0000000..ec3a65e
--- /dev/null
@@ -0,0 +1,3 @@
+This is not always the same since there is not always the same amount of memory
+available in the system. This is probably because the os has given memory to
+some other program.