From 6efa668ee8f16c38d65a8b71c7fbd44d339d9f53 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Thu, 8 Nov 2018 16:41:47 -0500 Subject: use vector to prevent memory leak --- pyisda/curve.pyx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index a575a96..d761867 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -525,7 +525,7 @@ cdef class SpreadCurve(Curve): cdef double* tenors_c = NULL cdef TCurve* curve = NULL cdef TCurve* new_curve = NULL - cdef double* rates = NULL + cdef vector[double] rates cdef unsigned int includes = 0 cdef size_t i cdef bint freeup = False @@ -587,12 +587,10 @@ cdef class SpreadCurve(Curve): 'M', b'NONE') else: - rates = malloc(n_dates * sizeof(double)) - for i in range(n_dates): - rates[i] = 1000 + rates = vector[double](n_dates, 1000) curve = JpmcdsMakeTCurve(today_c, end_dates_c, - rates, + rates.data(), n_dates, 5000., ACT_360) -- cgit v1.2.3-70-g09d2