@@ -400,7 +400,7 @@ void Serializer::serializeArray(const Serializer* _this, OutputData& outData, co
400
400
auto v = polymorph.staticCast <oatpp::Vector<Float64>>();
401
401
402
402
// get size of header + vector size * sizeof each element (size + data)
403
- auto dataSize = sizeof (PgArrayHeader) + v->size () * sizeof (PgElem);
403
+ auto dataSize = sizeof (PgArrayHeader) + v->size () * ( sizeof (PgElem) + sizeof (v_float64) );
404
404
outData.dataBuffer .reset (new char [dataSize]);
405
405
outData.dataSize = dataSize;
406
406
outData.dataFormat = 1 ;
@@ -418,12 +418,16 @@ void Serializer::serializeArray(const Serializer* _this, OutputData& outData, co
418
418
pgArray->header .index = 0 ;
419
419
420
420
// stuff in the elements in network order
421
+ auto *elemBuff = reinterpret_cast <p_uint8>(pgArray->elem );
421
422
for (int i=0 ; i < v->size (); i++) {
422
- pgArray->elem [i].size = htonl (sizeof (v_float64));
423
+ *reinterpret_cast <p_uint32>(elemBuff) = htonl (sizeof (v_float64));
424
+ elemBuff += sizeof (v_int32);
423
425
v_float64 fValue = v->at (i);
424
426
auto pVal = reinterpret_cast <p_int64>(&fValue );
425
- pgArray->elem [i].value [0 ] = htonl (*pVal >> 32 );
426
- pgArray->elem [i].value [1 ] = htonl (*pVal & 0xFFFFFFFF );
427
+ *reinterpret_cast <p_uint32>(elemBuff) = htonl (*pVal >> 32 );
428
+ elemBuff += sizeof (v_int32);
429
+ *reinterpret_cast <p_uint32>(elemBuff) = htonl (*pVal & 0xFFFFFFFF );
430
+ elemBuff += sizeof (v_int32);
427
431
}
428
432
} else {
429
433
serNull (outData);
0 commit comments