Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Blazing fast and memory safe malloc implementation using rand.

License

NotificationsYou must be signed in to change notification settings

portasynthinca3/randalloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Run it!

git clone https://github.com/portasynthinca3/randalloc.gitcd randalloccat main.c # just kinda look at what the code doessh randalloc.sh

Use it!

  • Yankrandalloc.cfrom this repo and paste it into your project.
  • Call_init_alloc as 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!

Performance

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!

Memory safety

Assuming you are fortunate enough that your allocations don't overlap, your codewill be memory safe!

Thread safety

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.

Why?

  • I just discovered the--wrap linker flag and my mind was absolutelyblown.
  • I saw the original implementation in someone's Discord status.
  • Yes, I am a little child.

Licensing

This project is hereby licensed under theWTFPL.

Contribution Policy

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

Stars

Watchers

Forks

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp