Click here to Skip to main content
15,900,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Internationalize String Tables Pin
Erik Funkenbusch14-Feb-01 13:40
Erik Funkenbusch14-Feb-01 13:40 
QuestionHow to restore registory Pin
sakurajyousui13-Feb-01 23:07
sakurajyousui13-Feb-01 23:07 
GeneralRecordset object from VB to VC++ ocx Pin
13-Feb-01 22:27
suss13-Feb-01 22:27 
GeneralRe: Recordset object from VB to VC++ ocx Pin
l a u r e n14-Feb-01 6:56
l a u r e n14-Feb-01 6:56 
GeneralThreads & Critical Sections Pin
Gerry13-Feb-01 22:26
Gerry13-Feb-01 22:26 
GeneralRe: Threads & Critical Sections Pin
.::RockNix::.14-Feb-01 0:04
.::RockNix::.14-Feb-01 0:04 
GeneralContext menu on rightclick of Network neighborhood computer Pin
13-Feb-01 16:14
suss13-Feb-01 16:14 
GeneralMemory leak... Pin
13-Feb-01 16:11
suss13-Feb-01 16:11 
I found that there are some memory leaks when running it in NT.

Here are the source codes.

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>


typedef struct DATA
{
char *data;
DATA *next;
} DATA;


void test2(DATA *d)
{
if (NULL == d->data) {

d->data = new char [100000];
if (NULL == d->data) {
printf("No memory for d->data.");
return;
}
}
else {

DATA *dp = d;

while (dp->next != NULL) dp = dp->next;

dp->next = new DATA;
if (NULL == dp->next) {
printf("No memory for dp->next.");
return;
}

memset(dp->next, 0, sizeof (DATA));
dp->next->data = new char [100000];
if (NULL == dp->next->data) {
printf("No memory for dp->next->data.");
return;
}
}
}


void main(void)
{
printf("Press ENTER to start.\n");
_getch();

int i;

DATA d, *dp, *next;

memset(&d, 0, sizeof (DATA));

for (i = 0; i < 200; i++) {
test2(&d);
test2(&d);
test2(&d);
test2(&d);
test2(&d);
}

printf("Press ENTER to continue.\n");
_getch();

delete[] d.data;

dp = d.next;

i = 1;

while (dp != NULL) {

next = dp->next;

delete[] dp->data;

delete dp;

dp = next;

i++;
}

printf("i = %d.\n", i); // 1000 expected.

printf("Press ENTER to finish.\n");
_getch();
}

Pls help...;)
GeneralRe: Memory leak... Pin
13-Feb-01 16:54
suss13-Feb-01 16:54 
GeneralRe: Memory leak... Pin
Rui Lopes13-Feb-01 23:03
Rui Lopes13-Feb-01 23:03 
Generalrefresh, back and forward for my browser!!! Pin
Damion of Argayl13-Feb-01 11:31
Damion of Argayl13-Feb-01 11:31 
GeneralPropertySheet - Tab position on bottom Pin
David L Morris13-Feb-01 11:10
David L Morris13-Feb-01 11:10 
GeneralRe: PropertySheet - Tab position on bottom Pin
ov13-Feb-01 21:31
ov13-Feb-01 21:31 
QuestionHow to update a Dialog box Pin
Richard Cheng13-Feb-01 8:24
Richard Cheng13-Feb-01 8:24 
AnswerRe: How to update a Dialog box Pin
Christian Graus13-Feb-01 10:57
protectorChristian Graus13-Feb-01 10:57 
AnswerRe: How to update a Dialog box Pin
13-Feb-01 10:58
suss13-Feb-01 10:58 
GeneralPassing PCWSTR to a function Pin
Vickie13-Feb-01 8:23
Vickie13-Feb-01 8:23 
GeneralRe: Passing PCWSTR to a function Pin
Matt.W.13-Feb-01 23:10
Matt.W.13-Feb-01 23:10 
GeneralRe: Passing PCWSTR to a function Pin
l a u r e n14-Feb-01 6:51
l a u r e n14-Feb-01 6:51 
GeneralList Box Pin
Hadi Rezaee13-Feb-01 6:55
Hadi Rezaee13-Feb-01 6:55 
GeneralRe: List Box Pin
astibich13-Feb-01 7:02
astibich13-Feb-01 7:02 
GeneralWTL compile problem Pin
13-Feb-01 3:20
suss13-Feb-01 3:20 
GeneralMMC snap-in Pin
13-Feb-01 1:47
suss13-Feb-01 1:47 
GeneralFeel free to contact me(+) Pin
15-Feb-01 1:03
suss15-Feb-01 1:03 
GeneralRe: MMC snap-in Pin
5-Jun-01 16:54
suss5-Jun-01 16:54 

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.