SmartHeap detects Memory Leak

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MitchMitchell
    New Member
    • Oct 2006
    • 2

    #1

    SmartHeap detects Memory Leak

    Hi,
    We just managed to get SmartHeap up and running and it's returning the following as a memory leak. We're using ANSI C memory allocation and I'm still a newbie, so any help would be appreciated.

    We're passing in text "sometext" to a function that accepts a string pointer.

    The receiving function does a string duplicate to write the text to memory space and create a new pointer. SmartHeap is saying that a memory leak occurs with the "sometext".

    Here's an example of the call with "Locations as the string..

    WdgAppendTabAtt ribute( SdmAsWdg( pTlz->pSdm ), DID_TAB_1, "Locations" , -1 );

    Void Dynlink WdgAppendTabAtt ribute( PWDG pWdg, MediumInt id, PSTR pStr, MediumInt imageIdx )
    {
    PTCE pTce;

    WdgAssert( pWdg );

    pTce = TceCreate( id, pStr, imageIdx );

    DpaAppend( &pWdg->dpaTab, (POBJ) pTce );

    } /* End WdgAppendTabAtt ribute */


    Void Dynlink TceInit( PTCE pTce, MediumInt id, PSTR pStr, MediumInt index )
    {
    TceSetAssert( pTce );

    pTce->pStr = StrDuplicate( pStr );
    StrSqueeze( pTce->pStr, pTce->pStr, '&' );
    pTce->imageIdx = index;
    pTce->id = id;

    } /* End TceInit */

    The pTce->pStr is being destroyed in the DeInit, and it is definitely being called. The breakdown appears to be with passing a text string into the TceInit. (StrDuplicate just creates a new memory space, copies the string into the memory, and returns a pointer.

    Thanks for any help!
    Mitch
Working...