diff --git a/cnpy.h b/cnpy.h index 0d3bb4c..c7a0c23 100644 --- a/cnpy.h +++ b/cnpy.h @@ -247,10 +247,12 @@ namespace cnpy { } if(shape.size() == 1) dict += ","; dict += "), }"; - //pad with spaces so that preamble+dict is modulo 16 bytes. preamble is 10 bytes. dict needs to end with \n - int remainder = 16 - (10 + dict.size()) % 16; - dict.insert(dict.end(),remainder,' '); - dict.back() = '\n'; + // pad with spaces so that preamble+dict is modulo 64 bytes. preamble is + // 10 bytes. dict needs to end with \n + int remainder = 64 - (10 + dict.size() + 1) % 64; + dict.insert(dict.end(), remainder, ' '); + dict.push_back('\n'); + assert((dict.size() + 10) % 64 == 0); std::vector header; header += (char) 0x93;