[Stk] bugs regarding stk

Abhi Reddy ahbee0 at gmail.com
Wed Sep 10 09:59:08 PDT 2014


I tried subscribing to the mail List , but got no reply back. 

The "StkFrames :: operator=" seems to have a memory leak 

right now it looks like 

StkFrames& StkFrames :: operator= ( const StkFrames& f )
{
  data_ = 0;
  size_ = 0;
  bufferSize_ = 0;
  resize( f.frames(), f.channels() );
  dataRate_ = Stk::sampleRate();
  for ( unsigned int i=0; i<size_; i++ ) data_[i] = f[i];
  return *this;
}

but I think it should be

StkFrames& StkFrames :: operator= ( const StkFrames& f )
{
  resize( f.frames(), f.channels() );
  dataRate_ = Stk::sampleRate();
  for ( unsigned int i=0; i<size_; i++ ) data_[i] = f[i];
  return *this;
}

by setting data_ to 0 in  operator=  ,the free(data_) in the resize will never get called but malloc will. Resulting in a memory leak. 

also is it OK to have a StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) function in the FileLoop class? effects and instruments have one but FilePlayback classes do not. Can I add a function in file loop that looks like this?

stk::StkFrames& tick(stk::StkFrames &frames,unsigned int channel = 0){
        stk::StkFloat *samples = &frames[channel];
        unsigned int hop = frames.channels();
        for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
            *samples = tick();
        return frames;
    }
}
Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20140910/6c12ada4/attachment.html 


More information about the Stk mailing list