|
I'll try this out. As a side note, the free(newMsg) works fine... Its just the char* thats in the struct GUIQueue that doesnt seem to want to free... Ill reply soon on the results.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Yup, this segment of code works fine...
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Then some other piece of code is changing newMsg->data before free() is called. Either take away from your current program, or add to this temporary program, until you find the offending statement(s).
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Well it seems the mix up occurs somewhere between pushing the it on the queue, and taking it off. I tried just a push followed by a pop, and i run into the problem. Any ideas why?
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Jader89 wrote: Any ideas why?
Not without seeing the code for the 'push' and 'pop' operations.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
The queue:
std::queue<GUIQueue*> GUIQ;
the struct:
struct GUIQueue<br />
{<br />
bool isBmp;<br />
int size;<br />
char* data;<br />
};
other than that, i just imported the queue.h header file,
and used the methods push(), and front(), since pop doesnt really do anything
other than completely remove the front of the queue.
here is the failing code as one thread, also note, that without the push, and pop, the free()'s worked fine.:
GUIQueue* newMsg = (GUIQueue*)malloc( sizeof(GUIQueue) );<br />
memset( newMsg, 0, sizeof(GUIQueue) );<br />
newMsg->data = (char*)malloc( sizeof(msg.u.reqvid) );<br />
memcpy( newMsg->data, &msg, sizeof(msg.u.reqvid) + sizeof( MsgHeader ) );<br />
newMsg->size = sizeof(msg.u.reqvid) + sizeof(MsgHeader);<br />
newMsg->isBmp = true;<br />
GUIQ.push( newMsg );<br />
<br />
GUIQueue* test = (GUIQueue*)GUIQ.front();<br />
GUIQ.pop();<br />
if( test->data != NULL )<br />
{<br />
free(test->data);<br />
test->data = NULL;<br />
}<br />
if( test != NULL )<br />
{<br />
free(test);<br />
test = NULL;<br />
}
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Correction:
If i keep the same pointer name, newMsg, and call free on that, it will work for both ->data, and on itself. But if i switch pointers names ,( i.e. GUIQueue* test = newMsg ), then call do the same free()'s but on test, it fails.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
I figured out the problem, if you look back in my code, i malloc a certain amount, then do a memcpy that is bigger than that amount, causing it to do something bad... 8), easy error for alot work, lol.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
DavidCrow wrote: newMsg->data = (char*)malloc( sizeof(msg.u.reqvid) );
should that be something like :
newMsg->data = (char*)malloc( msg.u.reqvid * sizeof(char ) );
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Its a typedef struct, im pretty sure this works, cuase it works in other parts of my code.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
I think this might be a hack, but im gonna create another GUIQ, with ready to be freed pointers, and when there used in my other thread, they get thrown away in this queue, which the other thread checks, and if there is anything in there, its free's it. Seems like a lot of work to free memory. Wonder why you it must be local heap to be able to free it.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Didnt work, same problem.... Boo.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
I want a different behaviour for a button when keeping it pressed with the LButton of the mouse.
To repeat the BN_CLICKED using a timer inside the new class is no big deal, it all works fine and dandy.
The thing is that I want to add a new notification code to be repeated while the button is pushed in, something like BN_KEPTDOWN, but I'd like to pick a value that doesn't conflict with some other notification code in a later release of DevStudio and/or MFC (running on VC6 at the moment).
Are there some guidelines regarding creating new notification codes?
I tried MSDN but I was unable to find anything about this.
Links, anyone?
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
you can use WM_USER then just add to it if you need more than one
|
|
|
|
|
Probably, but WM_USER has nothing to do with notification codes since WM_USER is a message ID.
When you handle the BN_CLICKED event, a WM_COMMAND message is sent from the child to the parent with a 16-bit notification code in the WPARAM parameter of the message. The other 16 bits are the ID of the control and the LPARAM parameter is the window handle of the control.
This is normally taken care of by the framework/MFC.
What I want is a new notification code that is guaranteed not to conflict with other notification codes for buttons.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
how to obtain file permision (such as drwx---r-x) from web host by ftp connection?
any samples, comments or links?
thanks
includeh10
|
|
|
|
|
How about CFtpFileFind::IsReadOnly() , CFtpFileFind::IsDirectory() , CFtpFileFind::IsSystem() , CFtpFileFind::IsHidden() , and CFtpFileFind::IsArchived() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
no.
unix permission has 10 digits:
prwxrwxrwx
includeh10
|
|
|
|
|
As best as I can remember, they represent three groups of read/write/execute. Correct? What does the initial 'p' represent?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Here is the situation:
I have a main window, that can have many sub windows/objects. ie ComboBox, push buttons, radio buttons, text boxes etc.. Some of those objects inside that window are hidden and only become unhidden when an event happens, like a button being clicked or a Combobox item is selected.
The window that I am getting is a black box, that is that I dont get the code, and it can change at any given build.
Here is the problem:
I am still fairly new to MFC/Windows API. I have used hooks on other parts of the code, and was just wondering what hook would you use to find out if there was a hidden object that was about to become unhidden as a result of a button click or some other event. If there is no hook, is there another solution that I am not familliar with?
Any help/links on this would be extremely helpfull.
Thanks in advance.
MyJob = herdingCats();
Maddo
|
|
|
|
|
Hi Friends,
I am store some data into vector and mapping it long key for searching (1::1 mapping).Below code
---------------------.h file------------------------
typedef std::vector<item *=""> m_cache;
typedef std::map<long, item="" *=""> m_index;
typedef std::pair<long, item*=""> INDEX_ENTRY;
INDEX_ENTRY IndexEntry(Item * plu);
--------------------.cpp-------------------------
m_cache.push_back(item);
m_index.insert(IndexEntry(item));
-------------------------------------------------
Now the requirment is to retrive the same data with any of 2 different key long1 and long2 from the same vector(1::2 mapping). Can you please help me how to do this?
Thanks
-- modified at 11:13 Tuesday 25th October, 2005
|
|
|
|
|
Calling EgWin::Calibrate works only if i do some stuff like Write nothing before i call another void in an unmanaged dll. Why does it not work if i take out this stupid Console::Write("") ??
<code>
class EgWin
{
public:
EgWin() {}
~EgWin() {}
int Init() { return EgInit(&stEgControl);}
void Calibrate(IntPtr hwnd){Console::Write(""); EgCalibrate(hwnd);}
};
public __gc class EgWinProxy
{
public:
EgWinProxy(){}
~EgWinProxy(){}
int _EgInit(){return mpC->Init();}
void _EgCalibrate(IntPtr hwnd){mpC->Calibrate(hwnd);}
private:
EgWin * mpC;
};
</code>
|
|
|
|
|
Thanks for your help with Subclassing in Visual Studio 2003.
However I have a new problem.
When creating a Editbox to store initials in, i created the class correctly and linked it to a EditBox. The Subclass was called CInitials and was derived from CEdit. The problem came when I trying to add the WM_CHAR message.
It doesnt show up on the 'Add Event Handler' dialog. The message im trying to filter is OnChar.
Any help will be appreciated.
Thanks
Tom
|
|
|
|
|
Hi,
Follow this
CInitials::CEdit(derived from CEdit)
make a control variable from CInitials and link it to the editbox(through classwizard)
then you will be able to tap it on the CInitials::OnChar(..)(through classwizard),
or else add the EN_CHANGE handler this will also help you .
Regards
FarPOinter
|
|
|
|
|
Thanks, but im using Visual C++ 7.1 not Visual Studio 6.0.
Visual C++ 7.1 comes with Visual Studio 2003.
Thanks for the suggestion anyway.
Tom
|
|
|
|
|