Re: Memory problems when deleting a vector element
- From: newbee <c.sunita@xxxxxxxxx>
- Date: Wed, 13 Jun 2007 14:33:16 -0700
Sorry, mistake while copy pasting...
Correction:
typedef vector <entry*> tbl;
On Jun 13, 1:47 pm, newbee <c.sun...@xxxxxxxxx> wrote:
That is the actual code. It compiles fine, and most of the time if
runs fine as well. I did not write the code, but I am getting an
exception from this line. This is the trace:
MSVCRTD!_free_dbg+0x41
MFC42D!operator delete+0xf
MFC42D!CString::FreeData+0x18
MFC42D!CString::~CString+0x39
AppName!entry::~entry+0x53
AppName!entry::'scalar deleting constructor'+0x25
AppName!X::delete_owned+0xf7
....................................
delete_owned() is the function above that contains the offending
line.
Looks like the problem happens when it tries to delete the CString
func_name, but I don't know why.
While deleting the entry in the vector, I guess it might be better to
use some itertator to the vector, but that still doesn't explain my
Debug Assertion, which is either of the type
"_CrtIsValidHeapPointer(pUserData)", or "_BLOCK_TYPE_IS_VALID(pHead-
nBlockUse)"
Thanks.
On Jun 13, 1:01 pm, "Igor Tandetnik" <itandet...@xxxxxxxx> wrote:
newbee <c.sun...@xxxxxxxxx> wrote:
typedef struct {
CString func_name;
list req_list;
int owner_id;
void *p_func;
} entry;
typedef vector <entry> tbl;
class X
{...
tbl m_table;
}
In one of the member functions of Class X, occasionally, the operator
delete for CString for the "delete m_table[i]" line gives a problem.
The statement
delete m_table[i];
shouldn't even compile, since m_table[i] is not a pointer, but is of
type entry&. Show your actual code.
Also, define "gives a problem". What specificially goes wrong, and in
exactly what way?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- Re: Memory problems when deleting a vector element
- From: Igor Tandetnik
- Re: Memory problems when deleting a vector element
- References:
- Memory problems when deleting a vector element
- From: newbee
- Re: Memory problems when deleting a vector element
- From: Igor Tandetnik
- Re: Memory problems when deleting a vector element
- From: newbee
- Memory problems when deleting a vector element
- Prev by Date: Re: Memory problems when deleting a vector element
- Next by Date: Re: Memory problems when deleting a vector element
- Previous by thread: Re: Memory problems when deleting a vector element
- Next by thread: Re: Memory problems when deleting a vector element
- Index(es):
Relevant Pages
|