From 0e81d9a11c0ce07cafcdc8530bb2636b66c8d385 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Fri, 18 Feb 2011 10:31:14 +0000 Subject: [PATCH] replaced alloca() (a.k.a. cvStackAlloc) with AutoBuffer or vector() everywhere. cvStackAlloc() is still defined, but we do not need alloca() anymore to compile and run OpenCV (fixes #889 and may be some others) --- modules/ml/src/svm.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp index bc0cff94c..29225f89b 100644 --- a/modules/ml/src/svm.cpp +++ b/modules/ml/src/svm.cpp @@ -2006,16 +2006,8 @@ float CvSVM::predict( const float* row_sample, int row_len, bool returnDFVal ) c params.svm_type == ONE_CLASS ? 1 : 0; float result = 0; - bool local_alloc = 0; - float* buffer = 0; - int buf_sz = sv_total*sizeof(buffer[0]) + (class_count+1)*sizeof(int); - if( buf_sz <= CV_MAX_LOCAL_SIZE ) - { - buffer = (float*)cvStackAlloc( buf_sz ); - local_alloc = true; - } - else - buffer = (float*)cvAlloc( buf_sz ); + cv::AutoBuffer _buffer(sv_total + (class_count+1)*2); + float* buffer = _buffer; if( params.svm_type == EPS_SVR || params.svm_type == NU_SVR || @@ -2065,8 +2057,6 @@ float CvSVM::predict( const float* row_sample, int row_len, bool returnDFVal ) c else CV_Error( CV_StsBadArg, "INTERNAL ERROR: Unknown SVM type, " "the SVM structure is probably corrupted" ); - if( !local_alloc ) - cvFree( &buffer ); return result; }