to deallocate the memory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sugankanya86@gmail.com

    to deallocate the memory

    Hi all,
    there is a code snippet like this

    this -PClient = new IPCAMAClient (&tcpProfile, clientPriority) ;

    if (!this -PClient -isValid())
    {
    // The object is invalid, the connection was not
    established
    delete this -PClient;
    this -PClient = NULL;
    }
    else
    {
    // The Object is valid
    this -Valid = TRUE;
    }

    in the above case, whether the memory alloted by the new operator is
    released perfectly or not?
    since there is no delete operator in the else part,is this a memory
    leak?
  • Sharad

    #2
    Re: to deallocate the memory


    <sugankanya86@g mail.comwrote in message
    Hi all,
    there is a code snippet like this
    >
    this -PClient = new IPCAMAClient (&tcpProfile, clientPriority) ;
    >
    if (!this -PClient -isValid())
    {
    // The object is invalid, the connection was not
    established
    delete this -PClient;
    this -PClient = NULL;
    }
    else
    {
    // The Object is valid
    this -Valid = TRUE;
    }
    >
    in the above case, whether the memory alloted by the new operator is
    released perfectly or not?
    since there is no delete operator in the else part,is this a memory
    leak?
    Is this the complete code? Perhaps not. Post the complete minimal code.


    Comment

    Working...