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

fix a bug of CvSeq#push

CvSeq<Fixnum>#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.
This commit is contained in:
ser1zw 2012-10-28 12:50:53 +09:00
parent 1037cf0a8e
commit 352a5e3981

View file

@ -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);