Allocation Conflict Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Majuer

    Allocation Conflict Error

    Hi,
    I have a class in one DLL. Something like this:
    class CLASS1
    {
    MyData* pData;
    CLASS1()
    {
    pData = NULL;
    }
    Load()
    {
    pData = new MyData;
    }

    ~CLASS1()
    {
    if (pData)
    pData = delete pData;
    }
    }
    Then in another DLL.
    I have
    CLASS1 myClass;
    myClass.Load();
    ....


    For release build, in boundscheker, I got this error message at the
    destructor of CLASS1 (pData = delete pData;)

    Allocation Conflict: Attempting to call global_operator _delete on
    pointer 0x322E5D8, that was allocated by HeapAlloc.

    Why the "new" was using HeapAlloc while the "delete" use
    "global_operato r_delete"(defin ed in afx.inl)?

    Thanks!
  • Jack Klein

    #2
    Re: Allocation Conflict Error

    On 31 Oct 2003 11:41:06 -0800, silviashe@hotma il.com (Majuer) wrote in
    comp.lang.c++:
    [color=blue]
    > Hi,
    > I have a class in one DLL. Something like this:
    > class CLASS1
    > {
    > MyData* pData;
    > CLASS1()
    > {
    > pData = NULL;
    > }
    > Load()
    > {
    > pData = new MyData;
    > }
    >
    > ~CLASS1()
    > {
    > if (pData)
    > pData = delete pData;
    > }
    > }
    > Then in another DLL.
    > I have
    > CLASS1 myClass;
    > myClass.Load();
    > ...
    >
    >
    > For release build, in boundscheker, I got this error message at the
    > destructor of CLASS1 (pData = delete pData;)
    >
    > Allocation Conflict: Attempting to call global_operator _delete on
    > pointer 0x322E5D8, that was allocated by HeapAlloc.
    >
    > Why the "new" was using HeapAlloc while the "delete" use
    > "global_operato r_delete"(defin ed in afx.inl)?
    >
    > Thanks![/color]

    Ask in a Windows programming newsgroup. None of DLL, HeapAlloc, or
    global_operator _delete are defined by C++, they are all Microsoft
    specific.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c++-faq-lite/
    alt.comp.lang.l earn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

    Comment

    Working...