Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Memcpy doesn't allocate stuff on the heap. Memcpy also doesn't care about whether you're copying to/from heap or stack memory (or a memory mapped file, or a memory mapped camera buffer); memory is memory.

If the computer isn't able to keep up with the playback, you would probably get extremely obvious sharp clicks, very far from "the sound has a slightly 'hard edge'".

New and malloc are identical. Neither one will initialize any of the data. You also wouldn't call either in a loop; you would allocate a buffer once and then copy data into that buffer. You can see this in the code they posted:

    BYTE *sound_buffer = new BYTE [sizeof(BYTE) * nBytesInFile];
    hr = mmioRead(hFile, (HPSTR)sound_buffer, nBytesInFile);
That's the only memory allocation in the whole piece of code they posted. They're talking about the audio quality difference between playing audio from a single big buffer allocated by new vs playing from a single big buffer allocated by malloc.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: