Click here to Skip to main content
15,929,653 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Opening an access database in VC++ Pin
Phil J Pearson4-Mar-02 4:23
Phil J Pearson4-Mar-02 4:23 
Questiondetermine cpu time of a process ? Pin
3-Mar-02 8:15
suss3-Mar-02 8:15 
AnswerRe: determine cpu time of a process ? Pin
alex.barylski3-Mar-02 9:10
alex.barylski3-Mar-02 9:10 
GeneralRe: determine cpu time of a process ? Pin
3-Mar-02 9:48
suss3-Mar-02 9:48 
GeneralRe: determine cpu time of a process ? Pin
alex.barylski3-Mar-02 13:46
alex.barylski3-Mar-02 13:46 
Generalmerge sort Pin
3-Mar-02 5:46
suss3-Mar-02 5:46 
GeneralRe: merge sort Pin
Michael Dunn3-Mar-02 7:25
sitebuilderMichael Dunn3-Mar-02 7:25 
Generalplease.........................please..................... Pin
3-Mar-02 4:49
suss3-Mar-02 4:49 
The Problem is --Where and How to Delete the created objects with "new" Operator

Please mark the palce and solution..
i tried with somany ways but i am getting "Heap assertion"

and in Debugging mode it is showing MemoryLeak Detected
as follows:

Detected memory leaks!
Dumping objects ->
{172} normal block at 0x002F5F88, 500 bytes long.
Data: 44 3A 5C 50 72 6F 6A 65 63 74 73 5C 44 75 6D 70

and also i am getting the
First-chance exception in MyApp.exe (KERNEL32.DLL): 0x000006B5: (no name).

please give me the solution
I am very much worring about these problems please please....


This is Mycode:

I am declaring structures as follows:

1.For Database entries:
;;;;;;;;;;;;;;;;;;;;;;;

typedef struct{
char strName[MAX_PATH];
int nNumber;
int nCode;

}DB_DATA;

2:For Daily entries:
;;;;;;;;;;;;;;;;;;;;

typedef struct{
char strName[MAX_PATH];
int nNumber;
int nCode;

}DAILY_DATA;

Now i am using CTypedPtrList as follows:

1.For Database:
===============

typedef CTypedPtrList DB_DATA_LIST;
DB_DATA_LIST m_lstDbData;

2.For Initial List:
==================
typedef CTypedPtrList INITIAL_LIST;
INITIAL_LIST m_InitialList;

3.For Priority List:
====================

typedef CTypedPtrList PRIORITY_LIST;
PRIORITY_LIST m_PriorityList;



Initially i am getting all the data from database and store it in "m_lstDbData"
as follows:
############

while (EndOfFile)
{

DB_DATA * dbdata=new DB_DATA;

strcpy(dbdata->sName,rs.sName);
dbdata->nNumber=rs.nNumber;
dbdata->nCode=rs.nCode;

m_lstDbData.AddTail(dbdata);
MoveNext();

}

Preparing the InitialList as follows:
`````````````````````````````````````
Now i am checking the Dialy Register(one Text file contains record wise data) if
Daily Register values mactched with Database values then stored this values into InitialList.

do
{

POSITION nPos=m_lstDbData.GetHeadPosition();
for(int nPass=0;nPass<m_lstdbdata.getcount();++npass)
{
db_data="" *="" tempdbdata="new" db_data;=""
tempdbdata="m_lstDbData.GetAt(nPos);"
if(dialyreg="" ncode="=tempDbdata-">nCode)
{
DAILY_DATA * tempDailyData=new DAILY_DATA;
strcpy(tempDailyData->sFileName,str);
tempDailyData->nNumber=tempDbdata->nNumber;
tempDailyData->nCode=tempDbdata->nCode;
InitialList.AddTail(tempDailyData);

}//end if(DialrRegCode==tempDbdata->nCode)
m_lstDbData.GetNext(nPos);
}//end for(int nPass=0;nPass<m_lstdbdata.getcount();++npass)

}while(endof daily="" reg);="" this="" is="" do="" while="" loop=""

<<<<<<<<<<<<<<<<<<<<<<<<<="">>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Next I am preparing PriorityList according the nCode(assending):
````````````````````````````````````````````````````````````````````
while(!InitialList.IsEmpty())
{

POSITION nPos=InitialList.GetHeadPosition();

DAILY_DATA * TempHeadPosData=new DAILY_DATA;
TempHeadPosData=InitialList.GetAt(nPos);//Head Position Priority
nStuctPos=InitialList.Find(TempHeadPosData);
nHPosCode=TempHeadPosData->nCode;
for(int nIndex=0;nIndex<initiallist.getcount();nindex++)
{
daily_data *="" tempnextposdata="new" daily_data;
tempnextposdata="InitialList.GetNext(nPos);
nNextPosCode=TempNextPosData-">nCode;
if(nHPosCode>nNextPosCode)
{
nStuctPos=InitialList.Find(TempNextPosData);
int nTempHold=nHPosCode;
nHPosCode=nNextPosCode;
nNextPosCode=nHPosCode;

}//end if(nHPosCode>nNextPosCode)
else
{
if(nHPosCode==nNextPosCode)
{
//here i am doing somethine
}//end if(nHPosCode==NextPosPriority)

}//end else
}//end for(int nIndex=0;nIndex<initiallist.getcount();nindex++)

daily_data="" *="" tempnewdata="new" daily_data;
tempnewdata="InitialList.GetAt(nStuctPos);"
prioritylist.addtail(tempnewdata);
initiallist.removeat(nstuctpos);
}="" end="" while(!initiallist.isempty())



finally="" i="" am="" getting="" the="" data="" from="" prioritylist="" and="" send="" it="" to="" mydll(mydll="" do="" update="" database)=""
``````````````````````````````````````````````````````````````````````````````````````````````````
while(!prioritylist.isempty())
{

position="" pos="PriorityList.GetHeadPosition();
DAILY_DATA" filedata="new" daily_data;
filedata="PriorityList.GetAt(Pos);
strTemp.Format("%s",filedata-">szName);

nCode=filedata->nCode;

if(nCode>=1)
{
//call MyDll
PriorityList.RemoveAt(Pos);

}//end if(nCode>=1)
else
{
PriorityList.RemoveAt(Pos);
}
strTempPath=strPath;

}//end while(!PriorityList.IsEmpty())

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Now the Problem is --Where and How to Delete the created objects with "new" Operator

Please mark the palce and solution..
i tried with somany ways but i am getting "Heap assertion"

and in Debugging mode it is showing MemoryLeak Detected
as follows:

Detected memory leaks!
Dumping objects ->
{172} normal block at 0x002F5F88, 500 bytes long.
Data: 44 3A 5C 50 72 6F 6A 65 63 74 73 5C 44 75 6D 70

and also i am getting the
First-chance exception in MyApp.exe (KERNEL32.DLL): 0x000006B5: (no name).

please give me the solution
I am very much worring about these problems please please....





suma k
GeneralRe: please.........................please..................... Pin
Tim Smith3-Mar-02 5:10
Tim Smith3-Mar-02 5:10 
Generalhere is one memory leak Pin
3-Mar-02 5:11
suss3-Mar-02 5:11 
GeneralRe: here is one memory leak Pin
Christian Graus3-Mar-02 9:02
protectorChristian Graus3-Mar-02 9:02 
GeneralRe: Thanks i got the solution Pin
5-Mar-02 4:08
suss5-Mar-02 4:08 
GeneralRe: Thanks i got the solution Pin
5-Mar-02 4:08
suss5-Mar-02 4:08 
GeneralVSS Header comments Pin
Darren Schroeder3-Mar-02 4:39
Darren Schroeder3-Mar-02 4:39 
GeneralRe: VSS Header comments Pin
Anders Molin3-Mar-02 4:43
professionalAnders Molin3-Mar-02 4:43 
Questionusing namespace std; <-- is evil? Pin
Travis D. Mathison3-Mar-02 4:28
Travis D. Mathison3-Mar-02 4:28 
AnswerRe: using namespace std; <-- is evil? Pin
Todd Smith3-Mar-02 4:41
Todd Smith3-Mar-02 4:41 
AnswerRe: using namespace std; <-- is evil? Pin
Tim Smith3-Mar-02 5:00
Tim Smith3-Mar-02 5:00 
AnswerRe: using namespace std; <-- is evil? Pin
Travis D. Mathison3-Mar-02 5:07
Travis D. Mathison3-Mar-02 5:07 
AnswerRe: using namespace std; <-- is evil? Pin
Felix Cho3-Mar-02 12:37
Felix Cho3-Mar-02 12:37 
GeneralRe: using namespace std; <-- is evil? Pin
Christian Graus3-Mar-02 12:57
protectorChristian Graus3-Mar-02 12:57 
GeneralRe: using namespace std; <-- is evil? Pin
Tim Smith3-Mar-02 13:11
Tim Smith3-Mar-02 13:11 
GeneralRe: using namespace std; <-- is evil? Pin
Christian Graus3-Mar-02 13:48
protectorChristian Graus3-Mar-02 13:48 
GeneralRe: using namespace std; <-- is evil? Pin
Tim Smith3-Mar-02 13:57
Tim Smith3-Mar-02 13:57 
GeneralRe: using namespace std; <-- is evil? Pin
Christian Graus3-Mar-02 15:24
protectorChristian Graus3-Mar-02 15:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.