To the tune of Sound of Silence by Simon & Garfunkel:
Hello malloc() my old friend,
I've come for mem'ry once again,
Because a pointer silently creeping,
Filled buffer that I was keeping,
And the signal that I trapped was a bus error.
Didn't care.
Because I still... have malloc()
There were pages that I missed.
My OS had sent them to disk.
Try my best to not hit swap,
Looking for data I could safely drop,
I compressed some bits that I kept stored in place
Freed some space.
But then I still... used malloc().
It uses hooking to intercept calls to malloc() and read(), calls the real functions, generates a square wave whose frequency is based on the size of the operation, dumps the generated sound data to WAV, returns the output of the real function calls.
Reminds me of when I was a kid, and I had a Tandy CoCo and a tape recorder deck that was the only way to save any programs you wrote on it. I tried playing the data tape a few times.
Yes! I used to have an Amstrad CPC 464 with a tape deck and it would play the tape through its internal speaker as it was loading a program into memory. The amount of time sat around watching screens like this:
Yeah, the result of the sizeof operator always compiles to a constant. It may vary from system to system and compiler to compiler, but it's written into the executable as a constant.
It's always the same for your compiler. Using sizeof improves the portability of the code. Because sizeof is calculated at compile time it doesn't make the code any less efficient.
We often think about pointers as being 4 bytes but that isn't necessarily the case. How would a 32 bit pointer map to the addressable memory of 64 bit hardware?
Depending on your application I can see where you might still want to clamp the result. However, I think you're right in this case since the clamped range doesn't make much sense here.
I'm reminded of some of my favourite C 1-liners for synthesis:
main(t){
for(t=0;;t++)
putchar(t*(((t>>12)|(t>>8))&(63&(t>>4))));
//putchar(t>>7|t%45)&(t>>8|t%35)&(t>>11|t%20); // try this too!
}
.. there's a whole world of 1-liners for synthesis out there, and some of them, frankly, are astounding. Sound is such a beautiful way to understand math ..
Very cool, though I'm having trouble getting any audio out trying it myself. I can build & LD_PRELOAD the .so fine, but the pipe to aplay produces jibberish in the terminal without audio.
25 comments
[ 2.3 ms ] story [ 62.6 ms ] threadhttps://soundcloud.com/glowdon/jingy-compiler-1#t=6:00
https://www.youtube.com/watch?v=OvChkOHgDIo
We often think about pointers as being 4 bytes but that isn't necessarily the case. How would a 32 bit pointer map to the addressable memory of 64 bit hardware?
It was like demos; I would be stunned at the emergent complexity and compactness, and it would only elicit shrugs from friends.
See viznut's (seminal) intro to the genre.
http://countercomplex.blogspot.fi/2011/10/algorithmic-sympho...
https://www.youtube.com/watch?v=GtQdIYUtAHg
Great stuff, eh?
https://soundcloud.com/glowdon/the-sounds-of-malloc#t=7:18
https://soundcloud.com/glowdon/the-sounds-of-malloc#t=8:40
https://soundcloud.com/glowdon/the-sounds-of-malloc#t=12:00