COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-08-2017, 05:59 AM   #1
mibes
Human being with feelings
 
Join Date: Apr 2017
Posts: 36
Default confusing malloc error problem with chunks example

I've been messing around with the stepper tool in the chunks example of WDL-ol. I've made it so the number of steps displayed is dynamically adjustable. Fine.

But when the destructor runs (closing the plugin) I get an error about trying to delete an unallocated pointer. I don't understand why because I am testing for nulls before deleting.


this is the significant part of the constructor:

Code:
  {
  ...

    float sliderWidth = ((float) mDrawRECT.W() / (float) mStepsDisplayed);

    mSteps = new double[numSliders];
    for(int i=0; i<numSliders; i++)
    {
        mSteps[i] = 0.;
    }

    for(int i=0; i<mStepsDisplayed; i++)
    {
      int lpos = (i * sliderWidth);
      mSteps[i] = 1.;

      mSliderBounds[i] = new IRECT(mDrawRECT.L + lpos , mDrawRECT.T, mDrawRECT.L + lpos + sliderWidth, mDrawRECT.B);
    }

    mHandleWidth = handleWidth;
  }

...

and this is the destructor:

Code:
  ~MultiSliderControlV()
  {
    delete [] mSteps;
      

    for(int i=0; i<mNumSliders; i++)
    {
        if (mSliderBounds[i] != NULL)
        {
            delete mSliderBounds[i];
        }
    }
  }
mibes is offline   Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.