This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A C++ question regarding the delete operator


I have a generic C++ question that I haven't been able to find a
satisfactory answer to, so I thought that I would give it a try here.
 
Recently, I came across some code for a linked list where a pointer to a
structure is declared locally in a function and initialized. Later in
the function, the 'delete' operator is used on the pointer, yet the
'new' operator was never used to allocate any memory on the heap.
 
For example:
 
void fun
{
     struct ListNode* temp;
     temp = head    // head is a member of the Linked List class
 
     ///  more code ///
 
    delete temp;
};
 
Will there be any adverse affects if delete is used on the pointer
although the new operator had never been invoked?
 
Thanks for any help.
 
CHRIS.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]