diff options
| -rw-r--r-- | pyisda/curve.pyx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index 02bf22a..1322c9e 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -96,7 +96,7 @@ cdef class Curve(object): elif fmt == 0: r = self.buf.get()[:self.buf_size] elif fmt == 2: - packed_size = sizeof(TCurve) + curve.fNumItems * (sizeof(double) + sizeof(uint16_t)) + packed_size = size - curve.fNumItems * (sizeof(TDate) - sizeof(uint16_t)) r = PyBytes_FromStringAndSize(NULL, packed_size) dst = PyBytes_AS_STRING(r) src = <char*>curve @@ -108,6 +108,11 @@ cdef class Curve(object): (<uint16_t*>dst)[i] = (<TRatePt*>src)[i].fDate - ref_date ref_date = (<TRatePt*>src)[i].fDate (<double*>(dst + curve.fNumItems * sizeof(uint16_t)))[i] = (<TRatePt*>src)[i].fRate + size -= sizeof(TCurve) + curve.fNumItems * sizeof(TRatePt) + if size > 0: + src += curve.fNumItems * sizeof(TRatePt) + dst += curve.fNumItems * (sizeof(double) + sizeof(uint16_t)) + memcpy(dst, src, size) return r def __getstate__(self): |
