diff --git a/include/ehs/Serializer.h b/include/ehs/Serializer.h index 5234a41..594500a 100644 --- a/include/ehs/Serializer.h +++ b/include/ehs/Serializer.h @@ -396,7 +396,7 @@ namespace ehs } template - void WriteStr(const T* str, N inSize = 0) + void WriteStr(const T* str, const bool sizeKnown, N inSize = 0) { if (!inSize) while (str[inSize]) @@ -424,7 +424,8 @@ namespace ehs { Util::Copy(&data[offset], &str[0], bSize); - *(T*)&data[offset + inSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + inSize] = 0; } else { @@ -432,7 +433,8 @@ namespace ehs for (N b = 0; b < sizeof(T); ++b) data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } } else @@ -443,13 +445,15 @@ namespace ehs for (N b = 0; b < sizeof(T); ++b) data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } else { Util::Copy(&data[offset], &str[0], bSize); - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } }