|
cedric moonen wrote:
Both returned adresses point to memory that has been freed.
I also knew this and thats why i expected that the output of foo() and foo1() had to be the same.
cedric moonen wrote:
As a test, you could just reverse the calls of the function and check the results:
i've done it already but result is the same.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
how many times are you going to ask the same question ?
Yesterday[^], DavidCrow And Nishant Sivakumar already gave you some efficient enough answers...
what are you looking for man ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 4:27 Friday 23rd September, 2005
|
|
|
|
|
toxcct wrote:
how many times are you going to ask the same question ?
Yesterday[^], DavidCrow And Nishant Sivakumar already gave you some efficient enough answers...
what are you looking for man ?
Loo well at the question i asked yesterday and at this question .
I'm sure you will find difference
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
yep, you're right, i'm not well woken up this morning... sorry
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
no problem
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
hello,
today i tried to create a program- a new project. i tried with Managed C++, Windows Form Application (.NET), i even checked on Delphi. but, at the end, i found out MFC is really the best solution for a project i would create since i worked in MFC before.
i would really like to know if there is an option to get Windows Form Application controls working in mfc.
For example:
i would like to add to my application imagelist, then i would like to add 32bit ico and png files into it. the main reason is actually, that the default MFC support only 256 colors - BMP images and lowcolored ICO files. but i really want for my program to look as good as possible!
any ideas how to do that? thanks for all the info guys and gals
|
|
|
|
|
lordgreg wrote:
i would like to add to my application imagelist, then i would like to add 32bit ico and png files into it.
Google will give you heaps of hits on solutions to this problem. I don't recall what they are, but I was doing this with help from the web 6 years ago.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi
can any one tell me that how can i send message from a thread to the dll main, actually i thread is within the dll, now there is a need to display the message that stop the thread for a moment asking the user request to continue or not, now i want this message to be displayed from the dll and not from the thread (i.e outside the thread), i studied about send message and postmessages, but what actually should i do ,, i shall be thankful
for ur help
thanks
|
|
|
|
|
This is my understanading of the problem...
1. You have an application and a dll
2. You are creating a thread which thread proc is in the DLL function
3. You need to send a message to the Thread which reside insode the dll..
Am I right?
PostMessage and SendMessage are used to send or post a message to the same proc.. Obviously they are belongs to the Window and processed by the Window Proc. As you know Window and Thread are fundamentally different..
In your case, your have two threads (minimum, one is your application thread and another one is dll thread...
For sending messages between the threads you have to use PostThreadMessage() function. For that you need the thread id of the destination.
Hope this help you.. Let me know if you need more information...
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
I am getting a compilation error using strings...
I believe I need to convert a char* to a TCHAR?
char* str;
str = "test";
TCHAR pzFolder[1] = TEXT(str); // fails here with error C2440: 'initializing' : cannot convert from 'char *' to 'char [261]'
|
|
|
|
|
pzFolder is an array of chars. str is a char pointer. You need to use _tcscpy(pzFolder, str); (And pzFolder needs to be longer than 1 char.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I am trying to convert a time string to hexidecimal format with a fixed length of 4 bytes. When I do the conversion below I get 7D5 when what I want is 07D5. Is there an easy way to pad the left hand side of the string with zeros? I also need to do this with seconds where I will have to pad more than 1 zero. I know I can do some string length checks and add zeros but I think there is an easier way out there.
Thanks,
Ryan
SYSTEMTIME st;
short year;
GetSystemTime(&st);
year = st.wYear;
CString Trialtime;
Trialtime.Format("%X", year);
|
|
|
|
|
Ryan Riel wrote:
Is there an easy way to pad the left hand side of the string with zeros?
Sure.
Trialtime.Format("%04X", year);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks,
I tried just ("%4X", year) but that didn't do it. Now I know.
Thanks again
Ryan
|
|
|
|
|
Hi,
I'm writing a multithreaded app and I'm having some bizzare problems. I have a worker thread which has a critical section. As the application starts up, it locks a whole bunch of times, and unlocks a whole bunch more times, no problems, every single lock is followed by an unlock. Then I call Sleep, after I've called sleep, I try and lock the CCriticalSection again, and the worker thread hangs permanently. This is bizzare because I've put TRACE0s in every single function that has access to that critical section, and none of them are called while my worker is sleeping. It's like somehow my critical section is getting locked, even though nobody seems to be locking it. Does anyone have any bright ideas about how my CCriticalSection might be being locked without me realising it? Is there any good way of knowing when and who is locking my critical section?
Joel Holdsworth
|
|
|
|
|
Bizzare! Replacing the CCriticalSection with a CMutex made the problem go away !?!
Joel Holdsworth
|
|
|
|
|
That's weird.
The main differences between critical sections and mutices is (a) mutices work cross-process, and (b) have a different timing.
I suspect you still have a bug lurking in your code, that is hidden / uncovered depending on timing.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Agreed, however I time is not a luxury I have right now! I am seriously short of time.
Joel Holdsworth
|
|
|
|
|
what do u mean by sleep. You called Sleep()? That freezes the thread! You should never use that func if you want the thread to be able to process something else at the same time!
|
|
|
|
|
so let me understand this, you call each worker from your main process, then sleep in main? this s what you should do, but i suspect this is not the case...
a 'good' model:
while(1) {
// call your threadproc
sleep(L5);
// watever else
}
dont use sleep in threadproc, this suspends execution
|
|
|
|
|
No No! The worker does the sleeping! The main process never stops - it just runs the message pump!
Joel Holdsworth
|
|
|
|
|
Main process and the worker thread are both threads. You call Sleep in the w-thread, it will be suspended there sleepting, and not able to receive and new message. I assume your w-thread does task when told, i.e. when getting a message to trigger execution of certain functions. If your w-thread cannot receive message, no wonder your func does not get called, let alone hit your critical section.
|
|
|
|
|
Well, sleep() only sleeps for the time specified. As I understand the OP he has something like
<br />
...<br />
sleep(sometime);<br />
myCriticalSection.Lock()
here the sleep() call will only block the worker thread for sometime milliseconds and are thus not in itself a problem.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
thats the problem then, Sleep() suspends threads and may mess with the crit sect timing, movr Sleep() to main() and that should fix your issue. why do you sleep in worker threads anyway? do u see the oxymoron?
|
|
|
|
|
If, while debugging the code, the app hangs hit break (not stop).
By looking at the threads you can see what each is executing.
Put the CCriticalSection in the variable watch list and open it up.
Inside you should find the root critical section object.
One of the members of this structure is the owning thread.
Look in the debugger thread list and see what that thread is doing.
...cmk
Save the whales - collect the whole set
|
|
|
|