Click here to Skip to main content
15,908,775 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalkeeping child dialog open Pin
BlackDice3-Sep-04 7:03
BlackDice3-Sep-04 7:03 
GeneralRe: keeping child dialog open Pin
PJ Arends3-Sep-04 7:06
professionalPJ Arends3-Sep-04 7:06 
GeneralRe: keeping child dialog open Pin
BlackDice3-Sep-04 7:10
BlackDice3-Sep-04 7:10 
GeneralRe: keeping child dialog open Pin
David Crow3-Sep-04 7:15
David Crow3-Sep-04 7:15 
GeneralRe: keeping child dialog open Pin
BlackDice3-Sep-04 7:20
BlackDice3-Sep-04 7:20 
GeneralRe: keeping child dialog open Pin
David Crow3-Sep-04 7:36
David Crow3-Sep-04 7:36 
GeneralRe: keeping child dialog open Pin
BlackDice3-Sep-04 7:47
BlackDice3-Sep-04 7:47 
QuestionAny one help Memory Leak ? Pin
Amarelia3-Sep-04 7:02
Amarelia3-Sep-04 7:02 
Hi guys !
I have developed one application which continuously runs on server. But because of some memory leaks in my code it hangs out after certain time period. Can any one can help it out plz. Or any other function that can show the current memory or Total Commit memory or Memory Usage. Plz. My code is also pasted here. If you can show me some change in my code it will be worth while.
------------------------------------------------------------------
int __stdcall CompressEncode (char* sIn, char* sKey, char** sOut, long* lOutlen)
{
int iResult = 0;

if (strlen(sIn) > 400)
{
iResult = CompressData(sIn, sKey, sOut, lOutlen);
}
else
{
iResult = 1;
AES_EncodeForService(sIn, sKey, sOut, lOutlen);
if (!strstr(*sOut, "<AES_ENCODE>"))
iResult = -4;
}
return iResult;
}

int CompressData (char* sIn, char* sKey, char** sOut, long* lOutlen)
{
Byte *compr, *uncompr;
uLong comprLen = 16384*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;

if (zlibVersion()[0] != myVersion[0])
return -1;

compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);

if (compr == Z_NULL || uncompr == Z_NULL)
return -2;

uncomprLen = strlen (sIn);
int iResult = test_compress(compr, &comprLen, (Bytef*)sIn, uncomprLen);
if (iResult != 0)
return -3;

byte *buffer, key[32];
unsigned int bufLen;
unsigned int err;
ailaes demo;
char s2[33] = "";

int len = strlen(sKey);
if (len > 64)
len = 64;
for (int i = 0, j = 0; i < len; i ++, j ++)
{
char sTemp[2] = "";
sTemp[0] = sKey[i];
sTemp[1] = 0;

int c = 0;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c = atol(sTemp) * 16;
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c = 10 * 16;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c = 11 * 16;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c = 12 * 16;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c = 13 * 16;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c = 14 * 16;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c = 15 * 16;

sTemp[0] = sKey[i + 1];
sTemp[1] = 0;
i ++;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c += atol(sTemp);
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c += 10;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c += 11;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c += 12;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c += 13;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c += 14;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c += 15;

s2[j] = c;
}
s2[j] = 0;

// pad out the input string to be an even block size
err = demo.strToBlock((char*)compr, comprLen, &buffer, &bufLen);

memmove(key, s2, 32);
demo.init(CBC, key);

// encript the buffer
err = demo.encrypt(buffer, bufLen);
if (err != 0)
return -4;

// encode the crypto buffer so it can pass as a null terminated string
*sOut = ESCencode( (char*)buffer, bufLen);
*lOutlen = strlen(*sOut);

free (buffer);
free (compr);
free (uncompr);
buffer = NULL;
compr = NULL;
uncompr = NULL;
return 1;
}
int test_compress(Byte *compr, uLong *comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;

err = compress(compr, comprLen, (const Bytef*)uncompr, uncomprLen);
// CHECK_ERR(err, "compress");

return err;
}

int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}

int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;

stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;

err = deflateInit(&stream, level);
if (err != Z_OK) return err;

err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);

return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;

err = deflateEnd(&stream);
return err;
}

AnswerRe: Any one help Memory Leak ? Pin
David Crow3-Sep-04 7:10
David Crow3-Sep-04 7:10 
AnswerRe: Any one help Memory Leak ? Pin
Rick York3-Sep-04 13:09
mveRick York3-Sep-04 13:09 
GeneralDatabase work in Visual C++ Pin
Iftikhar Baig3-Sep-04 6:36
sussIftikhar Baig3-Sep-04 6:36 
GeneralRe: Database work in Visual C++ Pin
David Crow3-Sep-04 7:01
David Crow3-Sep-04 7:01 
GeneralRe: Database work in Visual C++ Pin
Imtiaz Baig3-Sep-04 7:08
sussImtiaz Baig3-Sep-04 7:08 
GeneralRe: Database work in Visual C++ Pin
David Crow3-Sep-04 7:14
David Crow3-Sep-04 7:14 
QuestionActiveX TypeLib Practices: property or method? Pin
KFournier3-Sep-04 6:28
KFournier3-Sep-04 6:28 
GeneralHey i am looking for real MSGINA code Pin
ThatsAlok3-Sep-04 6:21
ThatsAlok3-Sep-04 6:21 
GeneralRe: Hey i am looking for real MSGINA code Pin
Michael Dunn3-Sep-04 7:18
sitebuilderMichael Dunn3-Sep-04 7:18 
GeneralRe: Hey i am looking for real MSGINA code Pin
ThatsAlok3-Sep-04 19:44
ThatsAlok3-Sep-04 19:44 
GeneralRe: Hey i am looking for real MSGINA code Pin
David Crow7-Sep-04 7:51
David Crow7-Sep-04 7:51 
GeneralRe: Hey i am looking for real MSGINA code Pin
ThatsAlok7-Sep-04 23:09
ThatsAlok7-Sep-04 23:09 
Generalexcel automation!! Pin
pnpfriend3-Sep-04 5:56
pnpfriend3-Sep-04 5:56 
GeneralRe: excel automation!! Pin
David Crow3-Sep-04 6:11
David Crow3-Sep-04 6:11 
GeneralRe: excel automation!! Pin
pnpfriend3-Sep-04 6:56
pnpfriend3-Sep-04 6:56 
GeneralRe: excel automation!! Pin
David Crow3-Sep-04 7:02
David Crow3-Sep-04 7:02 
GeneralRe: excel automation!! Pin
pnpfriend3-Sep-04 9:02
pnpfriend3-Sep-04 9:02 

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.