|
uh. What have you written? I have read it in many ways, it simply is not making sense.
Please refine your question if you would need someone to respond quickly.
Vipin - MVP
|
|
|
|
|
See here for how file monitoring is done.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Call FindFirstChangeNotification for each drive on the system, then do a WaitForMultipleObjects on the list of handles returned. See the docs for FindFirstChangeNotification.
onwards and upwards...
|
|
|
|
|
I've got to improve some code with memory leaks but how to identify their location in a source file, I've got only this output after program terminates and not a hint for a source code:
Detected memory leaks!
Dumping objects ->
{715} normal block at 0x00EAE450, 800 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{541} normal block at 0x0033FBC8, 4 bytes long.
Data: <0 > 30 00 00 00
{540} normal block at 0x0033FA10, 5 bytes long.
Data: <000 > 30 30 30 00 CD
{279} normal block at 0x0033F8A0, 8 bytes long.
Data: < > 00 00 00 00 00 00 00 00
{273} normal block at 0x0033F6C0, 8 bytes long.
Data: < > 16 1E 00 00 EA 1D 00 00
{272} normal block at 0x0033F680, 2 bytes long.
Data: <01> 30 31
{268} normal block at 0x0033ED48, 4 bytes long.
Data: < > 00 00 00 00
{266} normal block at 0x0033EE10, 2 bytes long.
Data: <1 > 31 00
{264} normal block at 0x0033ED88, 2 bytes long.
Data: <0 > 30 00
{232} normal block at 0x0033E3A0, 5 bytes long.
Data: < > 00 00 00 00 00
Object dump complete.
9ine
|
|
|
|
|
I recommend you use the following FREE leak detecting code:
http://code.axter.com/leaktracker.h[^]
You can download the assoicated DLL file via following link:
http://code.axter.com/leaktracker.zip[^]
This program will output the leak location (source-file-name, line-number). It will also give the Function name if your compiler supports it (like VC++7.x & GNU 3.x)
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
-- modified at 8:28 Wednesday 28th December, 2005
|
|
|
|
|
this does not work, first I just added leaktracker.h to the project, lib and dll to windows system dir and run the project from VS 2003. Then closed the project and get standart memory leak in VS output window but there was no file C:\zz_David_Maisonave_DefaultLeakTrackerLogFile.log after termination. Then I added #include to the .cpp file that created additional mem leak on purpose for testing and the project doesnt want to be compiled:
Compiling...
sGenDlg.cpp
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '('
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2226: syntax error : unexpected type 'size_t'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2059: syntax error : ')'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2143: syntax error : missing ';' before '['
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C3409: empty attribute block is not allowed
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'char ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'char ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(264) : warning C4005: 'new' : macro redefinition
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(10) : see previous definition of 'new'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(143) : error C2665: 'operator new[]' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(669): could be 'void *operator new[](size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(176) : warning C4244: '*=' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(188) : warning C4244: '*=' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(225) : error C2665: 'operator new' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(662): could be 'void *operator new(size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(231) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(234) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(237) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(259) : warning C4018: '<' : signed/unsigned mismatch
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(261) : warning C4018: '<' : signed/unsigned mismatch
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(290) : error C2665: 'operator new[]' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(669): could be 'void *operator new[](size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
9ine
|
|
|
|
|
In your sGenDlg.cpp file, the leaktracker.h must be the LAST included header.
If you include it before any other headers, you'll get compile errors, or runtime errors.
This program was originally developed using VS 2003, and then ported to GNU, Borland, and VC++ 6.0.
So it should definitely work on VS 2003.
FYI:
If it doesn't produce a log file, then either it was not compiled in DEBUG moder, or there were no memory leaks.
Since you didn't get compile errors the first time, I must assume it was not compiled in DEBUG mode.
If you don't see the following message when you compile, then the leak tracking code is not getting included.
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
If you wish to include the leak tracking code in the release version of your program you could do so by defining the following macro before including the header:
#define DEBUG_VERSION_
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
-- modified at 10:59 Wednesday 28th December, 2005
|
|
|
|
|
No I'm not inclined to use it in release version, I'm sure I've got debug compiler option and I included it as you said:
#include "stdafx.h"
#include "sGen.h"
#include "sGenDlg.h"
#include ".\sgendlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "Lib\lib.h"
#include "Lib\quantize.h"
#include "LibST\scomplexity.h"
// CsGenDlg dialog
#include "leaktracker.h"
CsGenDlg::CsGenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CsGenDlg::IDD, pParent)
, m_freq(10)
, m_sr(128)
, m_len(30), data(0)
, m_asize(2)
, qt(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
All the same compiler errors again? it doesnt want to be compiled, I use VS2003.
As for the first time I did not include leaktracker.h in any cpp file at all, which is not proper as I've read from its manual that it should be included at least in one file, and I ran it in debug mode (which we select from proj settings->config manager->active solution config), and to test it I used on purpose allocation of memory with new command without deleting it.
What is your suggestions?
look at the errors again:
Compiling...
sGenDlg.cpp
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '('
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2226: syntax error : unexpected type 'size_t'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2059: syntax error : ')'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '{'
and so on...
9ine
|
|
|
|
|
I see the problem. This is an over-sight on our part.
In your above code, you have the following:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
If you include the leaktracker.h file after the above line, that will cause the compile errors.
I've updated the leaktracker.h file so that it does an #undef for new.
#ifdef new
#undef new
#endif //new
You can download the new version, or just add the above 3 lines in the leaktracker.h file around line 177 (right before the new operator).
http://code.axter.com/leaktracker.h[^]
FYI:
If you're using MFC, also make sure to include the header after macros like IMPLEMENT_DYNCREATE.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
Thanks, great tool, now it works.
9ine
|
|
|
|
|
Please have a look at umdh.exe
Vipin - MVP
|
|
|
|
|
What is umdh.exe?
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
|
Rational Purify?
-Prakash
|
|
|
|
|
In your application, (if it is a MFC application, add the following in the InitInstance())
_CrtSetBreakAlloc(715);
it will break when it tries to allocation the leakage memory and you can find the source code.
Details can be "Memory Leak Detection" in VS.
|
|
|
|
|
Hello,
I have the Ascii Code from a character, for example: 101, which is e. How can I convert this int Value into a char or better CString ?
With best regards,
RedDragon2kx
|
|
|
|
|
itoa for int to string
never say die
|
|
|
|
|
Sorry but I think I wasn't clear enough. I need the integer(101) represtented as a char(e).
So I need to convert the ASCII code(101) back to the character it represents
|
|
|
|
|
what i understood is that u want to convert the ASCII value into char
char c=char(101);
another way
int i= 101;
char=static_cast<char>(101);
but keep in mind with range of c
never say die
-- modified at 6:15 Thursday 29th December, 2005
|
|
|
|
|
int asc_int;
CString S_temp;
S_temp.Format("%c",asc_int);
thats it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
If you remember that a char is just an int with a smaller range, then assigning an int to a char is just that, a simple assignment.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
int i_value;
char c_value;
c_value = static_cast<char>(i_value);
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
If i have an access database with a table called "USER" with fields ID, AGE, NAME, ADDRESS, and i want address of all users with age = 23, a simple sql query will do (SELECT * FROM USER WHERE blah blah)..
But when I have data in a CSV File, how would i build this sql query? select * from what?
Any help or pointers in this direction is highly appreciated.
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Rajesh R. Subramanian wrote: But when I have data in a CSV File, how would i build this sql query? select * from what?
Hi Rajesh,
csv file is nothing, just a comma seperated data and whole line denotes a record.
for executing query AFAIK, you have to import that in access and proceed in similiar way you mentioned above.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|