diff options
author | rose <rose@pinkro.se> | 2025-08-13 01:28:16 +0200 |
---|---|---|
committer | rose <rose@pinkro.se> | 2025-08-13 01:28:16 +0200 |
commit | b7be2c5498fd1844daadd9e78aa031c60be9cb44 (patch) | |
tree | 7ca176b6892b5ff23c5439025eaf552400007b8f | |
parent | e9b64be5230f0b498d8d78a8e67158a843594f83 (diff) | |
download | random-main.tar.gz random-main.tar.bz2 |
-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); |