uninitialized

malloc and obtaining recently freed memory

I am allocating the array and freeing it every callback of an audio thread. The main user thread (a web browser) is constantly allocating and deallocating memory based on user input. I am sending the uninited float array to the audio card. (example in my page from my profile.) The idea is to hear program state changes. When I call mall...

Does valgrind track memory initialization through drivers?

valgrind is reporting uninitialized memory errors from code like this: unsigned char buf[100]; struct driver_command cmd; cmd.len = sizeof(buf); cmd.buf = buf; ioctl(my_driver_fd, READ, &cmd); for(i = 0; i < sizeof(buf); i++) { foo(buf[i]); /* <<--- uninit use error from valgrind */ } If I memset() the buf before the driver call,...

What benefit is there of allowing a variable to be left uninitialized?

In many languages you're allowed to declare a variable and use it before initializing it. For example, in C++, you can write a snippet such as: int x; cout << x; This would of course return unpredictable (well, unless you knew how your program was mapping out memory) results, but my question is, why is this behavior allowed by compil...