|
-
July 4th, 2006, 05:23 PM
#1
Using delete [] inside a function
Hi,
I have a quick question: I using dynamic string inside function and the value returned by the function is the string. the problem is, after running some tests, i have a heap problem, memory leak.
As far as i know any data used by function is deleted upon exit so there is no need to use "delete [] uncompr ;".
Here is the func. code: (ps: all g_* are globals)
Code:
Byte* UnCompress (Byte* compr){
int err;
Byte *uncompr = new Byte [g_uncomprLen];
err = uncompress(uncompr, &g_uncomprLen, compr, g_comprLen);
if (err!=Z_OK)
{
printf("Uncompress() failed : %d\n", err);
return 0;
} else {
return uncompr;
}
}
I am trying to eliminate options so tell me what you think, can it be my problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|