Note that there are some explanatory texts on larger screens.

plurals
  1. POpointer being freed was not allocated error?
    primarykey
    data
    text
    <p>I have seen many posts for this error. But I'm not reserving memory dynamically or doing anything in destructor: This program is SSJF algorithm for selecting cylinder in operating system.</p> <p>I have a simple class called IO:</p> <pre><code>class IO { public: IO(); IO(int,int); void setIO(int,int); ~IO(); int trackNo; int arrival; int start; int end; bool finished; }; </code></pre> <p>Here is the implementation of the class::</p> <pre><code>IO::IO(int arr, int tNum) { this-&gt;arrival = arr; this-&gt;trackNo = tNum; this-&gt;start = 0; this-&gt;end = 0; } IO::IO() { } IO::~IO() { } void IO::setIO(int t1, int t2) { this-&gt;trackNo = t1; this-&gt;arrival = t2; } </code></pre> <p>And finally here is part of main program:</p> <pre><code>list&lt;IO&gt; myList; .... myList.push_back(tmpIO); //Add to the list ... list&lt;IO&gt; wt_list; </code></pre> <p>And later I'm trying to do some operations. I have deleted some of the part which is not related.</p> <pre><code> //list&lt;IO&gt;::iterator itMin; while(myList.size()&gt;0) { //If it is the first input just get it if(f) { IO selected = myList.front(); curr_time += selected.arrival + selected.trackNo; f=false; cout &lt;&lt; selected.arrival&lt;&lt;endl; lastPos = selected.trackNo; myList.pop_front(); } //Check if there is any item to add to queue while(myList.front().arrival &lt; curr_time) { wt_list.push_back(myList.front()); myList.pop_front(); //Error is coming from this line } while(wt_list.size()&gt;0) { } </code></pre> <p>Error message:</p> <p>malloc: <strong>* error for object 0x10f68b3e0: pointer being freed was not allocated *</strong> set a breakpoint in malloc_error_break to debug</p> <p>Anyone can help me and explain why I get this error and how can I skip it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload