From 352a5e3981559bda2473190c182cf9dda3305926 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 28 Oct 2012 12:50:53 +0900 Subject: [PATCH] fix a bug of CvSeq#push CvSeq#push stores always 0 to sequences in some environments. seq = CvSeq.new(Fixnum) seq.push(10, 20, 30) seq.to_a #=> [10, 20, 30] expected, but [0, 0, 0] returned This commit fixes the problem. --- ext/opencv/cvseq.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/opencv/cvseq.cpp b/ext/opencv/cvseq.cpp index 28fcdc4..11865a3 100644 --- a/ext/opencv/cvseq.cpp +++ b/ext/opencv/cvseq.cpp @@ -332,13 +332,13 @@ rb_seq_push(VALUE self, VALUE args, int flag) { CvSeq *seq = CVSEQ(self); VALUE klass = seqblock_class(seq), object; - void *elem = NULL; + volatile void *elem = NULL; int len = RARRAY_LEN(args); for (int i = 0; i < len; ++i) { object = RARRAY_PTR(args)[i]; if (CLASS_OF(object) == klass) { if (TYPE(object) == T_FIXNUM) { - int int_elem = FIX2INT(object); + volatile int int_elem = FIX2INT(object); elem = &int_elem; } else { @@ -346,9 +346,9 @@ rb_seq_push(VALUE self, VALUE args, int flag) } try { if (flag == CV_FRONT) - cvSeqPushFront(seq, elem); + cvSeqPushFront(seq, (const void*)elem); else - cvSeqPush(seq, elem); + cvSeqPush(seq, (const void*)elem); } catch (cv::Exception& e) { raise_cverror(e);