Code: Select all
memset(buffer,0,sizeof(float*)*bufferLength);
Code: Select all
memset(buffer,0,sizeof(float*)*bufferLength);
sizeof(float*) in 32bits is 32bits, but in 64bits, it's 64bits, which is twice the actual size of your buffer (explanation for those who hadn't seen it).matt42 wrote:So I was wondering why my 64 bit build was crashing, but 32 bit was fine. Then I found this hidden gem:
Code: Select all
memset(buffer,0,sizeof(float*)*bufferLength);
I don't think so, pointer arithmetic is done with float*, so the size would lack a *4 factor. This is what is interesting with range based C++ calls like std::fill.avasopht wrote:If you must use C, memset(buf_ptr, 0, ((buf_ptr+buf_size) - buf_ptr)) works too, but also see suggestions above.
Exactly, fill eliminates that error in logic.Miles1981 wrote:I don't think so, pointer arithmetic is done with float*, so the size would lack a *4 factor. This is what is interesting with range based C++ calls like std::fill.avasopht wrote:If you must use C, memset(buf_ptr, 0, ((buf_ptr+buf_size) - buf_ptr)) works too, but also see suggestions above.
Code: Select all
void func(const std::string& s);
void func(bool v);
...
func("abcd"); // converts from char* to bool and calls the 2nd version of func.
Code: Select all
if (val = 1) { blub }
Code: Select all
if (strcmp(sz, "do_blub_if_same")) { blub }
© KVR Audio, Inc. 2000-2024
Submit: News, Plugins, Hosts & Apps | Advertise @ KVR | Developer Account | About KVR / Contact Us | Privacy Statement