home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,595 of 33,346   
   cpp4ever to Shan   
   Re: Memory deallocation   
   01 Nov 11 05:39:33   
   
   795cda60   
   From: n2xssvv.g02gfr12930@ntlworld.com   
      
   On 01/11/11 10:57, Shan wrote:   
   > FieldValues = new vector();   
   >   
   >   
   >   I have the above FieldValues in a class as private member. How should   
   > I deallocate the memory allocated by this vector. Also I am populating   
   > the vector with  dynamically allocated. I want make sure that   
   > char* memory also deallocated when I destroy the instance of the   
   > class.   
   >   
   >   
   > Thanks for any help.   
   >   
   > Thanks,   
   >   
   > Shan   
   >   
   >   
      
     I assume the vector is allocated on construction and therefore freed   
   on destruction. The 'FieldValues' variable will need to be checked if it   
   is NULL before the vector is used/deleted, and reset to NULL after the   
   vector has be deleted.   
     Based on the vector containing dynamically allocated data I would   
   recommend a separate member function to delete the vector contents   
   before deleting the vector. In fact I would recommend you provide member   
   functions to handle/use the vector usage interfaces, in effect creating   
   a user specific container class to fit your requirements.   
      
   cpp4ever   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca