thanks for the response. Yes i have declared m_StVector in App class. So i need to clear it. but even i do m_StVector.clear() then still i see those memory leaks that are due to the first node of the link list... well I am still stuck how to free those.
Madan Chauhan
Posts
-
problem while freeing a link list within a vector structure [modified] -
problem while freeing a link list within a vector structure [modified]Hi all.
I have a link list in a vector structure. It throws exception while freeing first node of the list. This is the sample code-//////////Declaration//////
typedef struct _TEST_STRUCT
{
TCHAR _tchTemp[MAX_PATH];
__int64 i64Temp;
DWORD dwTemp;
_TEST_STRUCT *Next;
}TEST_STRUCT;typedef struct _TEST_VECTORST
{
int nVal;
TEST_STRUCT m_ListInVector;}TEST_VECTORST;
std::vector<TEST_VECTORST> m_StVector;
////////////////////////////////////////////////////
/////////Fill Structure//////////////CString csVal = L""; csVal = L"hello"; for (int i = 0; i < 2; i++) { memset (&wVectorSt, 0x00, sizeof(TEST\_VECTORST)); ptrList = NULL; wVectorSt.nVal = i + 1; int j = 0; while (j<10) { if (ptrList == NULL) { ptrTemp = (TEST\_STRUCT\*)calloc(1,sizeof(TEST\_STRUCT)); \_tcscpy(ptrTemp->\_tchTemp, csVal); ptrTemp->dwTemp = 10+j; ptrTemp->i64Temp = 100+j; ptrTemp->Next = NULL; ptrCurrent = ptrList = ptrTemp; } else { ptrTemp = (TEST\_STRUCT\*)calloc(1,sizeof(TEST\_STRUCT)); \_tcscpy(ptrTemp->\_tchTemp, csVal); ptrTemp->dwTemp = 10+j; ptrTemp->i64Temp = 100+j; ptrTemp->Next = NULL; ptrCurrent->Next = ptrTemp; ptrCurrent = ptrTemp; } j ++; } memcpy(&wVectorSt.m\_ListInVector, ptrList, sizeof(TEST\_STRUCT)); m\_StVector.push\_back (wVectorSt); } //////Free m\_StVector.m\_ListInVector//// for (int i = 0; iNext; free(ptrTemp); ptrTemp = NULL; } }
All the nodes become free but one that is very first node in the list does not free.
if i take start to free from first node like- ptrList = &m_StVector[i].m_ListInVector;then it throws exception immidiately and does not free any node...
Please give me some idea...
Thanks
modified on Tuesday, June 21, 2011 4:17 AM
-
How to assign Drive Letter to a volume?Hi all, There is a volume in my hard drive that currently does not has any drive letter. I need to assign a drive letter to this volume. Please suggest me some way to do so. If a volume has any drive letter already then I can change it's drive letter by getting it's GUID and assign any other drive letter easily. But if the volume does not has any drive letter then how can I get its GUID to assign a drive letter. If there is any other way to do this please suggest me. Thanks & Regards Madan
-
BYTE to binary conversionHi all, if I have BYTE bTemp = 0xAB; I need the binary stream of this BYTE value(ie 010101011) in to an integer Array. Is there any short way to do that rather to write the code to convert it? Thanks M Chauhan
-
How to convert a CString object to char array in VC++ MFChi .. Use _tcscpy() to copy from CString to TCHAR array; ex- CString csMystring = L"Hi all"; TCHAR tchChar[MAX_PATH]; memset(tchChar, 0x00, MAX_PATH); _tcscpy(tchChar, csMystring); Hope it will help. Thanks MChauhan
-
initialize disk using c++ codeWell I got it that is IOCTL_disk_create_disk.
-
initialize disk using c++ codeHi All, At one place in my code i need to run IOCTL_DISK_DELETE_DRIVE_LAYOUT, that execute smoothly. This IOCTL code make the disk signature as zero so it can not be initialize. I need to initialize this disk using code. Is there any API or any function that can initialize the disk? Please suggest me some way to initialize it using c++ code. Thanks MChauhan
-
executing .bat file in Vista64 bitThanks for replying. Yes all the commands are correct because if I run this batch file with command prompt then it execute successfully. Let me explain- I am running following three commands command1)- bcdedit /set {bootmgr} device boot > D:\m1.txt command2)- bcdedit /set {default} device boot > D:\m3.txt command3)- bcdedit /set {default} osdevice boot > D\m2.txt. These three commands clears Bootmgr of Vista. For runnong these commands I make a batch file and execute it with ShellExecute() For seeing output I used pipe. Then after ShellExecute() if I see these m1,m2,m3 files then these are blank. I am confused now.
-
executing .bat file in Vista64 bitHi All, In my application I need to execute some commands. For that I am making a .bat file and execute it using Shellexecute(). It is working well for Vista32 bit, but in Vista64 bit machine Shellexecute() is not running these commands(i am running with Admin privileges also). Does ShellExecute() not support Vista64 bit? Is there any other way for Vista64 bit. Thanks Madan
-
FSCTL_EXTEND_VOLUME failsHi, In my application I need to extend the size of a NTFS volume. I use IOCTL_DISK_GROW_PARTITION to grow partition boundary this executes successfully. But after this FSCTL_EXTEND_VOLUME fails with error #87 (incorrect parameter). Please anyone give me some idea that why this control code is failing. Thanks
-
check disk APIYes. I want to do the same thing with my code (at running stage of machine) that OS do itself at booting time.
-
check disk APIHi all, I am making an application using vc++, when the process complete I need to boot the machine and at booting time it ask for disk check for FAT32 volume. I dont want that user will see this check disk black screen. So I am trying to check the disk with my code before machine boot. Is there any win32API or any utility that checks disk so that I can implement it in to my code? I dont want to use Chkdsk Method of the Win32_LogicalDisk Class. One more option that I have to execute command chkdsk command on command prompt. But I am looking for any better option. Thanks Regards M Chauhan
-
Get drive letter of Hard driveThanks for your kind support. I will apply it today. Thanks Madan
-
Get drive letter of Hard driveHi all, My application is for windows Vista and XP. There are more than on Hard drive connected to my machine. I need to get Drive Letters of the Hard drive from which my system is booting. By using GetLogicalDriveStrings Function I can get the drive letters of all Hard drives. But how can I differentiate that this particular drive letter is the partition name of my booting Hard drive? The structure of disks are: disk0(Booting with this)- C D G disk1- E F H disk2- I J I need to get the C,D,G only. Thanks Madan
-
How to Create and format partitionsOH... Pardon me I have quoted you without reading this reply from ur side. I am just checking for these FMIFS.h and FMIFS.dll Thanks
-
How to Create and format partitionsThanks CMyLife. I am not sure that you will get my query today coz this thread is of one day old. I have successfully created the partition using IOCTL_DISK_SET_DRIVE_LAYOUT. But now I am stuck in formatting this raw partition. There is one function FormatEx() but it is only for Vista. Is there any other way to format partition without using DISKPART and SHFormatDrive like some ioctl code. Thanks
-
How to Create and format partitionsThanks CMylife. I am going to implement it now. I will consult you after trying it. thanks
-
How to Create and format partitionsHi all, I am creating an application for windows Vista, XP and 2003Server. In my application I need to create and format partitions(Extended and primary both). I do not want to use DISKPART utility. Is there any other way to do this job like by using any win32API or any function provided by Microsoft in MSDN? Please give me some suggestions. Thanks
-
Extend vloume using FSCTL_EXTEND_VOLUMEThanks for ur support CmyLife I done it.
-
Extend vloume using FSCTL_EXTEND_VOLUMEThanks for your guidance. I dont have any idea which API or function extend the boundary of partition. Please tell me if you know that one. thanks.