Commit 0e81d9a1 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

replaced alloca() (a.k.a. cvStackAlloc) with AutoBuffer or vector() everywhere.…

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)
parent 65a7f13a
......@@ -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<float> _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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment