title: Freeing two dimensional array of stack
body: <p>This is the edited code: </p>
  
  <p>I have a two dimensional stack, like </p>
  
  <pre><code>#define push(s,ele) s.list[++(s.last)]=ele
  
  typedef struct vp {
      short int v1,v2;
  }VPTYPE;  
  
  typedef struct VPLIST{
      int last;
      VPPTR *list;
  }VPLISTTYPE,*VPLISTPTR ;    
  
  VPLISTPTR v1v2;  
  v1v2=(VPLISTPTR)malloc(sizeof(VPLISTTYPE)*nof);  
  a=0;
  while(a&lt;100)
  {  //allocation part
     for(i=0;i&lt; nof;i++)  
     {  
        v1v2[i].list=(VPPTR *)malloc(20*(sizeof(VPPTR)));  
  
       for(i2=0;i2&lt; 10;i2++) //please note that I am not filling the array completely, in the actual code the value 10 is dependent on certain factors, which I am omitting for the sake of simplicty 
       {  
           v=(VPTYPE *)malloc(sizeof(VPTYPE));  
           push(v1v2[i],v); 
           v1v2[i]-&gt;v1=1;v1v2[i]-&gt;v2=2;
       }
     }
     // some algorithm goes on here which accesses these values in the stack
  
     // free memory part
    for(i=0;i&lt; nof;i++)  
     {  
        for(i2=0;i2&lt;= (v1v2[i2].last);i2++)
       {  
           free(v1v2[i2].list[i]); 
       }
     }
  
     a++;
  }
  </code></pre>
  
  <p>When I free the memory this way there is memory leakage. Please let me know where I am going wrong.</p>
  
  <p>Thank you very much.</p>