- Notifications
You must be signed in to change notification settings - Fork3
Blazing fast and memory safe malloc implementation using rand.
License
portasynthinca3/randalloc
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
randalloc is a 🚀BLAZING FAST, 🚀MEMORY SAFE and 🚀THREAD SAFEmemory allocator. It works like this:
void*malloc(size_ts) {return (void*)rand(); }
Actually,a bit more is required to actually makerand work like that. Goreadrandalloc.c,it's just 36 lines long.
git clone https://github.com/portasynthinca3/randalloc.gitcd randalloccat main.c # just kinda look at what the code doessh randalloc.sh- Yank
randalloc.cfrom this repo and paste it into your project. - Call
_init_allocas close to entry as possible. - Compile your project with
-Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=realloc. - Enjoy 🚀BLAZING FASTNESS, 🚀MEMORY SAFETY and 🚀THREADSAFETY in your very own project that you chose to write in a legacylanguage!
The allocator runs in O(1) time. And that constant is quite small, not gonna lie.
Have I measured it? No. But it's fast; like look at it!
Assuming you are fortunate enough that your allocations don't overlap, your codewill be memory safe!
This allocator does not need to take any extra precautions to ensure threadsafety. That not only means it's 🚀BLAZING SAFE, it's also 🚀THREADFAST!
Wait, no, I think I might have mixed up something.
- I just discovered the
--wraplinker flag and my mind was absolutelyblown. - I saw the original implementation in someone's Discord status.
- Yes, I am a little child.
This project is hereby licensed under theWTFPL.
Due to various compliance requirements, you are now required to submit a DNAtest in your first pull request to this repository. If it is found out that youare more than 50% Russian by blood, your pull request will be rejected.Additionally, if it is found out that you are more than 10% Russian by blood,you must provide one of the following or your pull request will be rejected:
- A photo of a valid ID or equivalent document proving that you are notcitizen of the Russian Federation;
- A photo of a valid residence permit or equivalent document issued by a stateother than the Russian Federation before Sept. 21st, 2022 (the start ofmobilization in the Russian Federation);
- A video of you burning down your Russian ID and passport and subsequentlysinglehandedly overthrowing your dictator.
In addition to all the requirements outlined above, you must prove that you havenever worked for a Russian-based company sanctioned by the glorious U.S. of A.
These requirements are retroactive; shall we ever find out that your status(family tree, citizenship, residency and/or employment history) now conflictsone or more of these requirements, your patch will be totally removed from thegit log. No revert commit, no anything. Just undo & force push.
NOTICE: This is a humorous policy that won't actually be applied. Of course,everyone who knows me is aware that I, myself, am Russian by nationality. Thereare actual contribution policies like this out in the wild though. I made thisone to poke fun at real anti-Russian discrimination in the open source communitythat was sparked by the Linux maintainers ban.
About
Blazing fast and memory safe malloc implementation using rand.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Contributors2
Uh oh!
There was an error while loading.Please reload this page.