Click here to Skip to main content
16,007,779 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to consume base64Binary xml using C++ ? Pin
Anthony_Yio13-May-03 1:24
Anthony_Yio13-May-03 1:24 
QuestionRegister TLB, does it makes sense ??? Pin
Braulio Dez13-May-03 1:23
Braulio Dez13-May-03 1:23 
QuestionMemory leak detection... the best solution? Pin
Raphael Kindt13-May-03 1:10
Raphael Kindt13-May-03 1:10 
AnswerRe: Memory leak detection... the best solution? Pin
Neville Franks13-May-03 1:29
Neville Franks13-May-03 1:29 
AnswerRe: Memory leak detection... the best solution? Pin
Hari Krishnan (Noida)13-May-03 2:48
Hari Krishnan (Noida)13-May-03 2:48 
GeneralRe: Memory leak detection... the best solution? Pin
Raphael Kindt13-May-03 3:28
Raphael Kindt13-May-03 3:28 
GeneralRe: Memory leak detection... the best solution? Pin
Hari Krishnan (Noida)13-May-03 3:44
Hari Krishnan (Noida)13-May-03 3:44 
GeneralRe: Memory leak detection... the best solution? Pin
paul413-May-03 5:25
paul413-May-03 5:25 
I use macros as a wrapper to the malloc, realloc and free functions. This way I can log all my memory allocations to a file, the following is a bit complicated, but works:

#define realloc(PTR, SIZE) \
logReallocPtr(PTR, realloc(PTR, SIZE), ck_memsize(PTR), SIZE, __FILE__, #PTR, __LINE__, NULL)
#define malloc(SIZE) \
logReallocPtr(NULL, malloc(SIZE), 0, SIZE, __FILE__, #SIZE, __LINE__, NULL)
#define free(PTR) \
logReallocPtr(PTR, NULL, ck_memsize(PTR), 0, __FILE__, #PTR, __LINE__, free)

// This function gets called for every malloc, realloc and free
void *logReallocPtr(void *oldPtr, void *newPtr, size_t oldSize, size_t newSize, const char *file, const char *func, size_t line, void(*_free)(void*)){
char modFile[MAX_PATH];
int i=strlen(file)-1;
FILE *out=NULL;
if(!oldPtr && !newPtr) return NULL;
while(out==NULL) out=fopen("\\debug_alloc.txt", "ab");
strcpy(modFile, file);
while(i>=0){ if(modFile[i]==':') modFile[i] = '_'; i--; }
if(out){
fprintf(out, "%d:%s:%s:%d:%d:%.8x:%.8x:%d:%d:\r\n", (int)time(NULL), modFile, func, line, getpid(), (size_t)oldPtr, (size_t)newPtr, oldSize, newSize);
fclose(out);
}else{
fprintf(stderr, "%d:%s:%s:%d:%d:%.8x:%.8x:%d:%d:\r\n", (int)time(NULL), modFile, func, line, getpid(), (size_t)oldPtr, (size_t)newPtr, oldSize, newSize);
}
if(_free && oldPtr) _free(oldPtr);
return newPtr;
}

GeneralRe: Memory leak detection... the best solution? Pin
paul413-May-03 5:27
paul413-May-03 5:27 
GeneralGDI System calls Pin
vikramlinux13-May-03 1:01
vikramlinux13-May-03 1:01 
Generalabout programing windows example Pin
賴凱全13-May-03 0:28
賴凱全13-May-03 0:28 
GeneralRe: about programing windows example Pin
Tibor Blazko13-May-03 0:38
Tibor Blazko13-May-03 0:38 
GeneralRe: about programing windows example Pin
Anthony_Yio13-May-03 1:13
Anthony_Yio13-May-03 1:13 
GeneralLVM_GETSUBITEMRECT Pin
JensB13-May-03 0:22
JensB13-May-03 0:22 
GeneralVisual Studio project loading problems Pin
Meghani12-May-03 23:58
Meghani12-May-03 23:58 
Generalfloating point arithmic Pin
roel_12-May-03 23:47
roel_12-May-03 23:47 
QuestionUsing IDE with a Python build-script fails? Pin
Moak12-May-03 23:27
Moak12-May-03 23:27 
AnswerRe: Using IDE with a Python build-script fails? - Solved Pin
Moak13-May-03 0:08
Moak13-May-03 0:08 
GeneralNewbie Question Pin
Jorgen E.12-May-03 23:24
Jorgen E.12-May-03 23:24 
GeneralRe: Newbie Question Pin
jhwurmbach12-May-03 23:35
jhwurmbach12-May-03 23:35 
GeneralRe: Newbie Question Pin
Jorgen E.12-May-03 23:40
Jorgen E.12-May-03 23:40 
GeneralRe: Newbie Question Pin
jhwurmbach12-May-03 23:55
jhwurmbach12-May-03 23:55 
GeneralRe: Newbie Question Pin
Jorgen E.13-May-03 0:04
Jorgen E.13-May-03 0:04 
GeneralRe: Newbie Question Pin
jhwurmbach13-May-03 1:08
jhwurmbach13-May-03 1:08 
GeneralRe: Newbie Question Pin
Jorgen E.13-May-03 1:19
Jorgen E.13-May-03 1:19 

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.