From d7eb9bcda3848ce1b3816d428e8dd66d9b0e02d8 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 8 Dec 2010 18:45:14 +0000 Subject: SMSPeakDetection bug fixes --- sms/sms.i | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sms/sms.i') diff --git a/sms/sms.i b/sms/sms.i index ad3fa29..a61d4b8 100644 --- a/sms/sms.i +++ b/sms/sms.i @@ -372,13 +372,16 @@ SMS_SpectralPeaks(int n) { SMS_SpectralPeaks *s = (SMS_SpectralPeaks *)malloc(sizeof(SMS_SpectralPeaks)); - s->nPeaks = n; - if((s->pSpectralPeaks = (SMS_Peak *)malloc(n * sizeof(SMS_Peak))) == NULL) + if(s == NULL) { - sms_error("could not allocate memory for spectral peaks"); + sms_error("Could not allocate memory for SMS_SpectralPeaks"); + return NULL; + } + if(sms_initSpectralPeaks(s, n) < 0) + { + sms_error("Could not initialise SMS_SpectralPeaks"); return NULL; } - s->nPeaksFound = 0; return s; } void getFreq(int sizeArray, sfloat *pArray ) -- cgit v1.2.3