Click here to Skip to main content
15,904,339 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Transparent image as background of a window. How? Pin
Richard MacCutchan12-Nov-11 3:08
mveRichard MacCutchan12-Nov-11 3:08 
GeneralRe: Transparent image as background of a window. How? Pin
Frozzeg12-Nov-11 5:37
Frozzeg12-Nov-11 5:37 
GeneralRe: Transparent image as background of a window. How? Pin
Richard MacCutchan12-Nov-11 6:32
mveRichard MacCutchan12-Nov-11 6:32 
AnswerRe: Transparent image as background of a window. How? Pin
Albert Holguin22-Nov-11 5:06
professionalAlbert Holguin22-Nov-11 5:06 
QuestionConvert Japanese charaters to multiByte Pin
anandvtra9-Nov-11 17:12
anandvtra9-Nov-11 17:12 
AnswerRe: Convert Japanese charaters to multiByte Pin
Richard MacCutchan9-Nov-11 22:27
mveRichard MacCutchan9-Nov-11 22:27 
QuestionAdding atl support to existing mfc application Pin
Coder Block7-Nov-11 19:29
Coder Block7-Nov-11 19:29 
QuestionVisual Leak Detector => Memory leaks on system functions? Pin
sypt4-Nov-11 23:00
sypt4-Nov-11 23:00 
Hi, i'm getting strange memory leaks on basic functions such as:
fopen_s, localtime_s, wprintf, or _wfopen. What could possibly be wrong with the code / memory management?

I'm using Visual Leak Detector 2.2.

Memory leak report:
http://pastebin.com/j4ubmgD6[^]

void logger::calibrateFile(){
	time_t t = time(0);
	struct tm now;
	errno_t err = localtime_s(&now, &t );//leak detected here???
	if (err)
    {
		printf("Invalid argument to localtime_s (logger).");
		exit(1);
	}
	char st[ 10 ];//guessing
	_itoa_s(now.tm_year + 1900, st, 10);
	string fname = (string)st;
	fname += '-';
	_itoa_s(now.tm_mon + 1, st, 10);
	fname += (string)st;
	fname += '-';
	_itoa_s(now.tm_mday, st, 10);
	fname += st;
	fname += ".txt";
	string _logFile = this->logDir + fname;
	if (this->logFile.compare(_logFile) != 0){
		if (this->flog.is_open())
			this->flog.close();
		this->logFile = _logFile;
		// file allready exists, we dont need to write an unicode byte
		if (this->fileExists(this->logFile.c_str())) this->fresh = false; 
		this->flog.open(this->logFile.c_str(), fstream::out | fstream::app);
		if (!this->flog.fail()){
			printf("IP.logFile = %s\n", this->logFile.c_str());
			/*if (this->fresh)
				this->writeUnicodeByte();//writes unicode byte*/
		}else
			printf("IP.logFile = failed (%s)!\n", this->logFile.c_str());
	}
	//delete now; //tried to make now a dynamic pointer and delete later on, but it didn't work, leak still was reported there multiple times
}


Detected leak example:
---------- Block 528 at 0x0236DC58: 228 bytes ----------
Leak Hash: 0x2583A208 Count: 1
Call Stack:
f:\dd\vctools\crt_bld\self_x86\crt\src\realloc.c (85): test.exe!_realloc_base + 0x17 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c (832): test.exe!realloc_help + 0x10 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c (1040): test.exe!_realloc_dbg + 0x1B bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c (1107): test.exe!_recalloc_dbg + 0x19 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\setenv.c (250): test.exe!__crtsetenv + 0x39 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\wtombenv.c (72): test.exe!__wtomb_environ + 0xB bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\getenv.c (131): test.exe!_getenv_helper_nolock + 0x5 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\tzset.c (165): test.exe!_tzset_nolock + 0xA bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\tzset.c (95): test.exe!__tzset
f:\dd\vctools\crt_bld\self_x86\crt\src\loctim64.c (82): test.exe!_localtime64_s
c:\program files (x86)\microsoft visual studio 10.0\vc\include\time.inl (121): test.exe!localtime_s + 0xD bytes
c:\users\zzz\zzz\code\c++ projects\test\parser\logger.cpp (40): test.exe!logger::calibrateFile + 0xD bytes
c:\users\zzz\zzz\code\c++ projects\test\parser\parser.cpp (11): test.exe!Parser::Parser
c:\users\zzz\zzz\code\c++ projects\test\test\test.cpp (27): test.exe!wmain + 0x26 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (278): test.exe!__tmainCRTStartup + 0x19 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (189): test.exe!wmainCRTStartup
0x760F339A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x772F9ED2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x772F9EA5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
50 D7 36 02 00 00 00 00 A0 41 20 00 FA 00 00 00 P.6..... .A......
C0 00 00 00 02 00 00 00 95 02 00 00 FD FD FD FD ........ ........
30 D0 36 02 78 B9 36 02 E0 B9 36 02 18 96 36 02 0.6.x.6. ..6...6.
E0 70 36 02 B0 71 36 02 28 72 36 02 C8 95 36 02 .p6..q6. (r6...6.
20 C8 36 02 80 C8 36 02 58 71 36 02 F8 C8 36 02 ..6...6. Xq6...6.
48 C9 36 02 B8 C9 36 02 08 CA 36 02 20 6B 36 02 H.6...6. ..6..k6.
88 6B 36 02 E0 6B 36 02 38 6C 36 02 88 6C 36 02 .k6..k6. 8l6..l6.
08 6D 36 02 60 6D 36 02 C0 6D 36 02 48 6E 36 02 .m6.`m6. .m6.Hn6.
98 72 36 02 28 67 36 02 80 67 36 02 80 66 36 02 .r6.(g6. .g6..f6.
90 68 36 02 E0 67 36 02 A8 69 36 02 20 6A 36 02 .h6..g6. .i6..j6.
F0 68 36 02 78 6A 36 02 B8 D1 36 02 F0 D0 36 02 .h6.xj6. ..6...6.
40 D1 36 02 00 D3 36 02 98 96 36 02 28 D2 36 02 @.6...6. ..6.(.6.
90 D2 36 02 50 D4 36 02 A0 D4 36 02 68 D3 36 02 ..6.P.6. ..6.h.6.
E8 D5 36 02 E8 D3 36 02 70 D7 36 02 00 00 00 00 ..6...6. p.6.....
FD FD FD FD ........ ........
C#
#include <string>
#include <fstream>
#include <iostream>
#include <stdio.h>  /* defines FILENAME_MAX */
#include <ctime> //to get datetime


//#ifdef WINDOWS //some day
    #include <direct.h>	//to get current directory
    #define GetCurrentDir _getcwd
/*#else
    #include <unistd.h>
    #define GetCurrentDir getcwd
 #endif*/
class logger
{
private:
    ofstream flog;
    bool fresh;                         //is our log file freshly created or reopened for writting?
    string logDir;                      // ".\log\" by default :)
    string logFile;                     // ".\log\YYYY-MM-DD.txt" by default :)
    //void flush();                     //my flush
    bool fileExists(const char* fname); //checks if file exists
    void directWrite(char* logline);    //writes directly bypassing argument check
    //void writeUnicodeByte();          //writes unicode byte to fresh file
public:
    void calibrateFile();				//checks for the current date, opens log file and prepares it for writing
}


modified 7-Nov-11 3:32am.

AnswerRe: Visual Leak Detector => Memory leaks on system functions? Pin
Richard MacCutchan5-Nov-11 3:54
mveRichard MacCutchan5-Nov-11 3:54 
GeneralRe: Visual Leak Detector => Memory leaks on system functions? Pin
sypt6-Nov-11 21:31
sypt6-Nov-11 21:31 
QuestionUse Unregistered tlb files Pin
SB_CodeForFun30-Oct-11 23:51
SB_CodeForFun30-Oct-11 23:51 
AnswerRe: Use Unregistered tlb files Pin
«_Superman_»6-Nov-11 15:33
professional«_Superman_»6-Nov-11 15:33 
QuestionCWnd::CreateEx Fails?! Pin
Kyudos24-Oct-11 10:21
Kyudos24-Oct-11 10:21 
AnswerRe: CWnd::CreateEx Fails?! Pin
Richard MacCutchan24-Oct-11 11:20
mveRichard MacCutchan24-Oct-11 11:20 
GeneralRe: CWnd::CreateEx Fails?! Pin
Kyudos24-Oct-11 11:59
Kyudos24-Oct-11 11:59 
AnswerRe: CWnd::CreateEx Fails?! Pin
Richard MacCutchan24-Oct-11 12:25
mveRichard MacCutchan24-Oct-11 12:25 
GeneralRe: CWnd::CreateEx Fails?! Pin
Kyudos24-Oct-11 12:54
Kyudos24-Oct-11 12:54 
GeneralRe: CWnd::CreateEx Fails?! Pin
Richard MacCutchan24-Oct-11 21:11
mveRichard MacCutchan24-Oct-11 21:11 
GeneralRe: CWnd::CreateEx Fails?! Pin
Kyudos24-Oct-11 14:09
Kyudos24-Oct-11 14:09 
QuestionHow to add ActiveX control to a WTL main frame Pin
sunmast18-Oct-11 0:25
sunmast18-Oct-11 0:25 
AnswerRe: How to add ActiveX control to a WTL main frame Pin
Jonathan Davies18-Oct-11 1:55
Jonathan Davies18-Oct-11 1:55 
AnswerRe: How to add ActiveX control to a WTL main frame Pin
Jonathan Davies18-Oct-11 1:58
Jonathan Davies18-Oct-11 1:58 
Questionsyslog.h analog in WIndows Pin
ShadowUz16-Oct-11 21:36
ShadowUz16-Oct-11 21:36 
SuggestionRe: syslog.h analog in WIndows Pin
Richard MacCutchan16-Oct-11 23:08
mveRichard MacCutchan16-Oct-11 23:08 
AnswerRe: syslog.h analog in WIndows Pin
Albert Holguin17-Oct-11 5:12
professionalAlbert Holguin17-Oct-11 5:12 

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.