GetMessage
-
Hi Everyone, I need some help!!! I have been retrieving my messages from the message queue in my thread using the GetMessage(). I've placed the message inside the MSG structure and retrieve the messaage contents by referencing msg.wParam. msg.wParam is an UINT value that represents the address of msg content, in this case, a dynamically allocated char * pointer. After using this string, I wanted to deallocate the memory for this char *ptr, doing this. delete (char *) msg.wParam; It compiles but didn't work. As suspected, msg.wParam isn't a ptr, it's an address! So I tried this. char *tmp; tmp = (char *) msg.wParam; delete tmp; It compiles Same problem. So what can I do? Everytime a new msg comes, the information in msg.wParam is rewritten. But I'm pretty sure that the memory allocation remains! :confused: Any help on this problem is greatly appreciated! Thanks! wilche
-
Hi Everyone, I need some help!!! I have been retrieving my messages from the message queue in my thread using the GetMessage(). I've placed the message inside the MSG structure and retrieve the messaage contents by referencing msg.wParam. msg.wParam is an UINT value that represents the address of msg content, in this case, a dynamically allocated char * pointer. After using this string, I wanted to deallocate the memory for this char *ptr, doing this. delete (char *) msg.wParam; It compiles but didn't work. As suspected, msg.wParam isn't a ptr, it's an address! So I tried this. char *tmp; tmp = (char *) msg.wParam; delete tmp; It compiles Same problem. So what can I do? Everytime a new msg comes, the information in msg.wParam is rewritten. But I'm pretty sure that the memory allocation remains! :confused: Any help on this problem is greatly appreciated! Thanks! wilche
try delete [] reinterpret_cast(msg.wParam);
-
try delete [] reinterpret_cast(msg.wParam);
John M. Drescher wrote: delete [] reinterpret_cast(msg.wParam); Oops I missed that in my reply. Thanks:)
-
try delete [] reinterpret_cast(msg.wParam);
-
delete (char *) msg.wParam; This deletes only 1 char not an array of char. Add [] to delete arrays. The reinterpret_cast<> is a c++ way of casting. John