diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2023-01-10 13:40:59 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2023-01-10 13:58:06 -0500 |
| commit | 5d3bf18797eabf2a9534388026ade2f02d57b311 (patch) | |
| tree | cf11236f758ee15de5e64a85a77fce4cc40b97fe | |
| parent | 658baede68db8bfaf6b72a4418fe49e8df02d7f5 (diff) | |
| download | pyisda-5d3bf18797eabf2a9534388026ade2f02d57b311.tar.gz | |
do not hardcode field sizes
| -rw-r--r-- | pyisda/curve.pxd | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/pyisda/curve.pxd b/pyisda/curve.pxd index 937a8f5..f372ca7 100644 --- a/pyisda/curve.pxd +++ b/pyisda/curve.pxd @@ -44,8 +44,8 @@ cdef extern from "farmhash.h" namespace 'util' nogil: uint64_t Hash64WithSeed(const char *buff, size_t len, uint64_t len) cdef inline size_t TCurve_size(const TCurve* curve) nogil: - return sizeof(int) + sizeof(TDate) + sizeof(double) + \ - sizeof(long) + sizeof(TRatePt) * curve.fNumItems + return sizeof(curve.fNumItems) + sizeof(TDate) + sizeof(curve.fBasis) + \ + sizeof(curve.fDayCountConv) + sizeof(TRatePt) * curve.fNumItems cdef inline unsigned char* serialize(const TCurve* curve, unsigned char* buf) nogil: memcpy(buf, &(curve.fNumItems), sizeof(curve.fNumItems)) @@ -54,10 +54,10 @@ cdef inline unsigned char* serialize(const TCurve* curve, unsigned char* buf) no buf += sizeof(TRatePt) * curve.fNumItems memcpy(buf, &(curve.fBaseDate), sizeof(TDate)) buf += sizeof(TDate) - memcpy(buf, &(curve.fBasis), sizeof(double)) - buf += sizeof(double) - memcpy(buf, &(curve.fDayCountConv), sizeof(long)) - return buf + sizeof(long) + memcpy(buf, &(curve.fBasis), sizeof(curve.fBasis)) + buf += sizeof(curve.fBasis) + memcpy(buf, &(curve.fDayCountConv), sizeof(curve.fDayCountConv)) + return buf + sizeof(curve.fDayCountConv) cdef inline void serialize_vector(const vector[TDate]& v, unsigned char* cursor) nogil: cdef size_t size = v.size() @@ -75,10 +75,10 @@ cdef inline const unsigned char* deserialize(const unsigned char* buf, TCurve* c buf += array_size memcpy(&curve.fBaseDate, buf, sizeof(TDate)) buf += sizeof(TDate) - memcpy(&curve.fBasis, buf, sizeof(double)) - buf += sizeof(double) - memcpy(&curve.fDayCountConv, buf, sizeof(long)) - buf += sizeof(long) + memcpy(&curve.fBasis, buf, sizeof(curve.fBasis)) + buf += sizeof(curve.fBasis) + memcpy(&curve.fDayCountConv, buf, sizeof(curve.fDayCountConv)) + buf += sizeof(curve.fDayCountConv) return buf cdef extern from "isda/cds.h" nogil: |
