Thread: Regarding Deleteing pointer!!!!!

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    26

    Unhappy Regarding Deleteing pointer!!!!!

    Hi Friends,

    Can anyone tell me I am getting an error like this....

    Code:
    Passing '*this->m_ptr_ptr' as parameter after its value was freed. Object '*this->m_ptr_ptr'  was used at line 184 after being freed by passing argument 1 to function 'delete' at line 173
    Here is the code snippet for your reference...

    Code:
    int *m_ptr_ptr = new com::att::ib::Core_V1_0::NVPair
    
                    .......
                    .......
                    .......
    
    void
    com::att::ib::Core_V1_0::IT_Gen_NVPairStreamable::replace_nonshareable_arg(
        CORBA::IT_InStream_ptr is,
        unsigned long _direction
    )
    {
        if (*m_ptr_ptr != 0)
        {
            if (m_own_value|| _direction == CORBA::ARG_OUT)
            {
                delete *m_ptr_ptr;
            }
            if (_direction != CORBA::ARG_INOUT)
            {
                *m_ptr_ptr = 0;
            }
            if (_direction == CORBA::ARG_IN)
            {
                m_own_value = IT_TRUE;
            }
        }
        read(is);
    }
    Please give me the solutions..

    Thanks in advance!!!!!

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    63
    I believe your problem is that you have deleted what the pointer refers to, but when you delete it you haven't removed the pointer's reference to that address. It is still pointing to that address. So set it to NULL.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. Quick Pointer Question
    By gwarf420 in forum C Programming
    Replies: 15
    Last Post: 06-01-2008, 03:47 PM
  3. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM