Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   pointer confusion :( (http://www.velocityreviews.com/forums/t288667-pointer-confusion.html)

mandatory 02-06-2005 07:45 PM

pointer confusion :(
 
hi,

im getting confused.

I have a memory leak in a routine and found that problem.

I have a routine:

void* PopQueue ()
{
void *item;

//...pop the item

return item;
}

The item was created with HeapAlloc() in the Push() routine.

In another segment of my program i have this:

void thereisdata()
{
MyqueueStruct *myitem;
myItem = (myitem *) PopQueue();
// process the data inside (this is working fine)
HeapFree (GetProcessHeap(),0, myItem); // ERRROR !
}

This raises an exception, and i can see that the memory isnt freed.

What im wondering now is what im doing wrong ? cant i free a pointer that
points to a memory location like the way i do it in PopQueue() ?

Hope you can help me - its starting to annoy me.

using WinXP.



Victor Bazarov 02-06-2005 08:16 PM

Re: pointer confusion :(
 
"mandatory" <okllsam@nptklooohs.ru> wrote...
> [..]
> I have a memory leak in a routine and found that problem.
>
> The item was created with HeapAlloc() in the Push() routine.
>
> In another segment of my program i have this:
>
> HeapFree (GetProcessHeap(),0, myItem); // ERRROR !
>
> This raises an exception, and i can see that the memory isnt freed.
>
> What im wondering now is what im doing wrong ? cant i free a pointer that
> points to a memory location like the way i do it in PopQueue() ?
>
> Hope you can help me - its starting to annoy me.


No, we can't. With the little code you provided it's only clear that
you're using some non-standard functions to allocate and free your
memory. You need to post your question where these functions are on
topic. I recommend comp.os.ms-windows.programmer.win32.




All times are GMT. The time now is 04:27 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.