The problem is the memset signature. You assume the length is the number of floats, while it's the number of *bytes* to be set to the specified value. https://en.cppreference.com/w/c/string/byte/memset