Pointers in For loops
Posted
by Bobby
on Stack Overflow
See other posts from Stack Overflow
or by Bobby
Published on 2010-04-01T18:08:32Z
Indexed on
2010/04/01
18:13 UTC
Read the original article
Hit count: 193
Quick question: I am a C# guy debugging a C++ app so I am not used to memory management.
In the following code:
for(int i = 0; i < TlmMsgDB.CMTGetTelemMsgDBCount(); i++)
{
CMTTelemetryMsgCls* telm = TlmMsgDB.CMTGetTelemetryMsg(i);
CMT_SINT32_Tdef id = telm->CMTGetPackingMapID();
ManualScheduleTables.SetManualMsg(i,id);
ManualScheduleTables.SetManExec(i,false);
}
Am I leaking memory every iteration b/c of CMTTelemetryMsgCls* telm = TlmMsgDB.CMTGetTelemetryMsg(i);
? The "CMTGetTelemetryMsg(int)" method returns a pointer.
Do I have to "delete telm;
" at the end of each iteration?
© Stack Overflow or respective owner