1 Replies - 2657 Views - Last Post: 31 July 2010 - 05:51 AM Rate Topic: -----

#1 onako  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 10

Freeing memory from a vector of structs

Posted 31 July 2010 - 05:17 AM

After I performed some operations on the vector of structs, I need to free the memory. I suppose clear() will not be sufficient, but I'm not sure how to perform individual delete.
typedef std::vector<VertexRAM> VecVertexRAM; // definition of a vector of structs

template <typename type>
void freeFromMemory(std::vector<type>& myVec) {
    typename std::vector<type>::iterator myIter=myVec.begin();
    while(myIter!=myVec.end()) {
	delete(*myIter);
	++myIter;
    }
    myVec.clear();
}


This outputs the following error:
Code:

error: type ‘struct VertexRAM’ argument given to ‘delete’, expected pointer

Any ideas on how to do this? Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Freeing memory from a vector of structs

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2130
  • View blog
  • Posts: 4,196
  • Joined: 30-May 10

Re: Freeing memory from a vector of structs

Posted 31 July 2010 - 05:51 AM

All sorts of progress being made here....
http://cboard.cprogr...or-structs.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1