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

fix a memory leak of GUI::Trackbar

This commit is contained in:
ser1zw 2012-02-05 19:08:46 +09:00
parent 903f2ae5c9
commit b44f936f95
2 changed files with 9 additions and 2 deletions

View file

@ -30,7 +30,7 @@ void define_ruby_class() {
return;
/*
* opencv = rb_define_module("OpenCV");
* GUI = rb_define_module_under(opencv, "GUI");
* GUI = rb_define_module_under(opencv, "GUI");
*
* note: this comment is used by rdoc.
*/
@ -46,13 +46,19 @@ void define_ruby_class() {
VALUE rb_allocate(VALUE klass) {
Trackbar *ptr;
return Data_Make_Struct(klass, Trackbar, trackbar_mark, 0, ptr);
return Data_Make_Struct(klass, Trackbar, trackbar_mark, trackbar_free, ptr);
}
void trackbar_mark(void *ptr) {
rb_gc_mark(((Trackbar*)ptr)->block);
}
void trackbar_free(void *ptr) {
Trackbar *trackbar = (Trackbar*)ptr;
free(trackbar->name);
free(trackbar);
}
/*
* call-seq:
* new(<i>name,maxval[,val],&block</i>)

View file

@ -37,6 +37,7 @@ void define_ruby_class();
VALUE rb_allocate(VALUE klass);
void trackbar_mark(void *ptr);
void trackbar_free(void *ptr);
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
VALUE rb_name(VALUE self);