1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

implemented rb_cvCreateMemStorage and replaced cvCreateMemStorage with rb_cvCreateMemStorage to create CvMemStorage as much as possible

This commit is contained in:
ser1zw 2011-04-28 00:36:34 +09:00
parent d9a7960949
commit 1ca99720c5
6 changed files with 36 additions and 6 deletions

View file

@ -220,7 +220,7 @@ rb_cvCreateImage(CvSize size, int depth, int channels)
* Creates a structuring element
* When memory allocation is failed, run GC and retry it
*/
IplConvKernel *
IplConvKernel*
rb_cvCreateStructuringElementEx(int cols, int rows,
int anchorX, int anchorY,
int shape, int *values)
@ -247,6 +247,35 @@ rb_cvCreateStructuringElementEx(int cols, int rows,
return ptr;
}
/*
* Creates memory storage
* When memory allocation is failed, run GC and retry it
*/
CvMemStorage*
rb_cvCreateMemStorage(int block_size)
{
CvMemStorage* ptr = NULL;
try {
ptr = cvCreateMemStorage(block_size);
}
catch(cv::Exception& e) {
if (e.code != CV_StsNoMem)
rb_raise(rb_eRuntimeError, "%s", e.what());
rb_gc_start();
try {
ptr = cvCreateMemStorage(block_size);
}
catch (cv::Exception& e) {
if (e.code == CV_StsNoMem)
rb_raise(rb_eNoMemError, "%s", e.what());
else
rb_raise(rb_eRuntimeError, "%s", e.what());
}
}
return ptr;
}
VALUE rb_module;
VALUE rb_opencv_constants;