diff options
-rw-r--r-- | silly-malloc/README | 3 | ||||
-rw-r--r-- | silly-malloc/meow.c | 10 | ||||
-rw-r--r-- | silly-malloc/teehee.c | 4 |
3 files changed, 3 insertions, 14 deletions
diff --git a/silly-malloc/README b/silly-malloc/README index 0d26192..f5a0804 100644 --- a/silly-malloc/README +++ b/silly-malloc/README @@ -5,6 +5,5 @@ Randomly allocate less memory than wanted ## Usage ```bash gcc -fPIC -shared teehee.c -o teehee.so -gcc meow.c -o meow -LD_PRELOAD=./teehee.so ./meow +LD_PRELOAD=./teehee.so <whatever program> ``` diff --git a/silly-malloc/meow.c b/silly-malloc/meow.c deleted file mode 100644 index 88c7e88..0000000 --- a/silly-malloc/meow.c +++ /dev/null @@ -1,10 +0,0 @@ -#define _GNU_SOURCE -#include <stdlib.h> -#include <stdio.h> - -int main () { - char *merow = malloc (9); - sprintf (merow, "meowmeow"); - printf ("%s\n", merow); - free (merow); -} diff --git a/silly-malloc/teehee.c b/silly-malloc/teehee.c index 635a413..ed92eb9 100644 --- a/silly-malloc/teehee.c +++ b/silly-malloc/teehee.c @@ -12,9 +12,9 @@ extern void *malloc (size_t size) { if (!real_malloc) return NULL; // lmao srand (time (NULL)); - int val = rand () % 3; + int val = (rand () % 2)+1; if (val > 1) { - long loss = rand () % (int) size; + long loss = (rand () % (int) size)+5; return real_malloc (size - loss); } else { return real_malloc (size); |