Populating AudioSampleBuffer

Hello,

I've just started playing with juce, I'm also a noob in field of c++ so forgive me if my question is stupid.

I wrote a function which resamples the audiobuffer to lower frequancy(for given numeber of samples) to "rBuffer". 

Thi looks like this:


AudioSampleBuffer* AudioSampler::resample(int64 numSamples, int64 from, int64 into, int64 start)
{
    DBG("resampluje");
    //if(!bBuffer) return 0;
    rBuffer->setSize(2, numSamples  + start, true, true);
    rBuffer->clear(); //!temp
    int spsPerPixel = bBuffer->getNumSamples() / numSamples;
    if(spsPerPixel < 1) spsPerPixel = 1;
    int64 c = 0;
    DBG("resampluje2");
    float* l =  new float[bBuffer->getNumChannels()];
    float* s = new float[1];
    DBG("ustawione tablice:" + String(bBuffer->getNumSamples())+ ":" + String(rBuffer->getNumSamples())+ ":" + String(spsPerPixel));
    for (int i = 0; i < rBuffer->getNumSamples(); i++){
        
        for (int j = 0; j < rBuffer->getNumChannels(); j++){
            
            s[0] = *(bBuffer->getSampleData(j) + (i * spsPerPixel));
            if(c > 695){ DBG("sampel:" + String(s[0]) + ":" + String(c));}
            rBuffer->addFrom(j, start + c, s,1);
            l[j] = s[0];
        }
        
        c++;
        
    }
    return rBuffer;
}

The rBuffer is created first in constructor of my class and set to 2 channel, 100 samples.

Then in my function I set it's size for given numeber of samples .

My problem is that when I dont call rBuffer->Clear(), only the first 100 samples are set to correct values and the rest are undefined values.

I don't want to always clear old samples. Can someone please explain me how it works?