Three (3) List classes to prevent memory leaks

Here are two template classes and one normal class designed to prevent memory leaks.

CMyList (template)
This class is a wrapper for the CList MFC template class. It adds extra functionality and allows its member items to serialise themselves (important for schema versioning).

CMyTypedPtrList (template) my personal favourate
This class is a wrapper for the CTypedPtrList MFC template class. The items pointed to will be properly deleted thus causing no memory leaks.

CMyObList (standard class)
This class is a wrapper for the CObList MFC class. The items pointed to will be properly deleted thus causing no memory leaks.

Downloads

Download demo project - 9 Kb
Download source - 3 Kb

History



Comments

  • Serialization update

    Posted by Legacy on 07/20/1999 12:00am

    Originally posted by: Simon Hughes

    The following additional code allows for proper serialization.
    
    

    Add the following to the CMyTypedPtrList template
    void Serialize(CArchive &ar)
    {
    if(ar.IsLoading())
    RemoveAll();
    CTypedPtrList<CObList, TYPE*>::Serialize(ar);
    }

    Add the following to the CMyObList class.
    void Serialize(CArchive &ar)
    {
    if(ar.IsLoading())
    RemoveAll();
    CObList::Serialize(ar);
    }

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • It's time high-level executives and IT compliance officers recognize and acknowledge the danger of malicious insiders, an increased attack surface and the potential for breaches caused by employee error or negligence. See why there is extra emphasis on insider threats.

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds