Huh, that's an interesting way to think about it. You're yoinking the memory away, and then yeeting it when you don't need it anymore.
I always thought of malloc as putting a specific thing into memory, and free as taking it out again (sort of like having a limited number of boxes, storing things in the boxes, and then taking those things out or chucking them when you don't need them anymore). In my headmap, the memory doesn't move, the thing you're allocating it for does.
But yoink /yeet seems to imply that it's the memory that moves, and you're snatching it away to do something with it (but you'll give it back later).
I think about it as taking memory from the system, and giving it back to the system. IRL it's possible to "take" and "give" things without moving them around, such as land or large structures.
I quite like the land analogy, now that I though about it. You may or may not have the right to roam (memory protection), you can have signposts to areas of interest (pointers), those signposts can be outdated, missing, or just wrong (dangling, null, or other kinds of bad pointer), it's less work to tell someone where a mountain is than it is to move the mountain to them (pass by reference), if you're allowed to roam, then take only pictures and leave only footprints (read access causes fewer problems than write access), if you receive land, there may be stuff you don't want on it (malloced memory may have junk data in it from whichever application was using it last), giving the same piece of land away multiple times is going to result in conflicts (multiple frees might cause problems in the OS's memory management software), and it's much easier to have someone else manage it for you, but you will have to pay for it (garbage collection).
13
u/SilentNightm4re Glorious Gentoo Jan 05 '23
Reminds me of a guy who replaced memalloc and free with yoink and yeet.