|
Trollslayer wrote:
Are they paying you anything ?
Nope. They have somekind of agreement with our teachers and because of that the students were given some projects from that company.
|
|
|
|
|
So the company gets the benefit, the teachers get something and you do the work ?
Make sure you have copyright !
The tigress is here
|
|
|
|
|
The parser is only a part of the entire project and I don't have enough time left to make one.
I just need one that will know which statement is an if/for/while/switch/goto/label, to detect the functions, functions calls, return etc. I just need to know the structure of the program not to make the calculations and the operations. Or to make me the AST.
Thanks.
|
|
|
|
|
Hi All,
In an ActiveX dll, I have created UI and worker thread. But I am not able to allocate dynamic memory using "new" operator in worker thread. It allocates 500 bytes successfully but fails for more than 1000 byte.
Can any one tell me why this might be happening?
Thanks,
Amit.
|
|
|
|
|
Is your code using TerminateThread(...) anywhere? I learned the hard way some time ago how that kills your processes address space (due to the thread's stack address space not being made available again).
See what error code is being set (GetLastError() ) right after the allocation fails.
Does malloc(...) fail as well? What about other dynamic allocation functions?
Lastly, try using the debug CRT heap functions to verify that none of the heap structures have been stepped on (due to a memory over/under-run), like _CrtCheckMemory(...) .
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi James,
Thanks for the reply,
I have already tried it with malloc, malloc works fine until I allocate 975 bytes, but when I exceed that limit; it fails.
Moreover the application crashes, so I can not see the Last Error for that thread...
Thanks n Regards,
Amit
|
|
|
|
|
Hi,
I forgot to mention one thing in earlier reply, I use AfxEndThread( ) function to kill the thread, and not TerminateThread( )...
May I ask u, What were the problems u were getting when u were using TerminateThread( ),
Does that AfxEndThread( )also creates same problem that were created by TerminateThread( )?
Thanks n Regards,
Amit.
|
|
|
|
|
Amit Mulay wrote:
May I ask u, What were the problems u were getting when u were using TerminateThread( ),
When your thread is allocated, it gets its stack space. In Win32, this defaults to 1MB, but can be changed. Since threads operate in your process' address space, the memory (address) for the thread's stack exists in your process space.
When a thread exits normally (it returns from its ThreadProc ), the memory area reserved for its stack gets returned back to your process. But if you kill the thread, it never gets cleaned up correctly, and that reserved address space remains unavailable.
Over time, this can consume your process' address space and will cause new threads to fail creation, or memory allocation to fail because even though free memory does exist, your process' memory area has no more available addresses (range) to map that memory in or to reserve for the thread's stack.
Think of it like being in a candy store, with plenty of money. You start buying candy and filling your pockets. You then eat the candy, but you put the empty candy wrappers back into your pocket. After a while, your pockets will be full of empty wrappers, and you cannot hold any more candy, even though more candy is available and you still have money to buy it. You just do not have the "space" for anymore because you did not "clean up" the wrappers, you kept them.
Amit Mulay wrote:
Does that AfxEndThread( )also creates same problem that were created by TerminateThread( )?
No, because it does not cause the thread to exit in the same way. Since this function is called from within the thread, the thread "knows" it is ending and cleans itself up (via endthreadex(...) ).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
I just tried with GetLastError( ) function, and found that the error number is 998 i.e. "Invalid Access to memory location". Its name is "ERROR_NOACCESS"
Thanks n Regards,
Amit.
|
|
|
|
|
My first guess would be that something got stepped on in either your address space or in the heap. ERROR_NOACCESS actually means that an exception (Access Violation) was encountered internally within an underlying function.
Try using that debug function I posted earlier and see if it can detect if anything is wrong. Not all overruns are detected by the debug heap, especially if the overrun happens AFTER the memory is deallocated.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Malloc or new doesn't fail unless your system is out of memory (which I doubt).
There are two things that can be going on:
1. Prior to allocating the memory, you have managed to trash your memory heap thus causing the call to fail. Try using _CrtCheckMemory before and after the call to malloc.
2. The malloc is actually working just fine, but due to other bugs in your code, the routine is failing and you are misdiagnosing the problem as an allocation failure. I see this happen very often. Usually by people who can't believe their software has bugs so they blame the compiler. However, experienced programmers do this to.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Malloc or new doesn't fail unless your system is out of memory (which I doubt).
Or you are trying to allocate too much memory...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Normally allocating memory is not affected by threads, since the whole thing is synchronized with a semaphore (critical section).
Try single-step debugging to check if the error comes from CRT code or from windows itself.
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
Normally allocating memory is not affected by threads, since the whole thing is synchronized with a semaphore (critical section).
[Pedantic Hat On]
Technically, it is affected, and it is because of the Critical Section used to synchronize access to the heap in the default runtime memory allocator. If multiple threads are abusing the heap, they will lock each other out from time-to-time, which will hinder performance.
[Pedantic Hat Off]
That is actually one of the reasons developers sometimes see a dramatic decrease in performance when they start using multiple threads - bad memory practices.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hello,
I was wondering, is there a way to retrieve the key associated with a value when you have only the iterator?
Lets take the following code example:
typedef std::map<int, std::string> MyMap;
MyMap map;
for( MyMap::iterator iter = map.begin();
iter !< map.end();
iter++;
{
}
Is this possible and if yes, how can I achieve this?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I see now that a map iterator contains both the key and the value in a pair... What a dumb question it was indeed...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
<br />
typedef std::map<int, std::string> MyMap;<br />
MyMap myMap;<br />
<br />
for (int i=0; i<10;i++)<br />
myMap[i] = "Test";<br />
<br />
MyMap::iterator myIterator;<br />
<br />
for(myIterator = myMap.begin();myIterator != myMap.end();myIterator++)<br />
{<br />
int key = myIterator->first;<br />
string value = myIterator->second; <br />
}<br />
Hope this helps.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Nilesh K. wrote:
myIterator->first;
Thats what you get for not paying attention...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
An iterator over a map contains a std::pair object. You can access the current map key by using iter->first, and the current map value by using iter->second.
Regards,
--Mike
|
|
|
|
|
Hi guys,
I tried to use POST to send string to a text box in the website.
But it return me an error, said "The server unable to implement the request"
.
What goes wrong? Need help and advice
thanx
|
|
|
|
|
Try to ask this question in the web development forum! Here most people don't know or know to little about webdev to answer you unclear question. Even if someone knows it, I doubt that he / she will answer.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
dex_ter11 wrote:
I tried to use POST to send string to a text box in the website.
are using Visual C++ post data or some other Language
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
sorry for the unclear information. What should i do, to send a string to a text box of a html page using visual C++?
thanx
|
|
|
|
|
Then you have to get the Current Object of the INTEREXPLORE WINDOW i.e. IWebBrowser control.
using IWebBrowser control you can retrieve whole HTML page present in the BROWSER, Remember Browser can only display the HTML pages, .ASP are just HTML PAGES developed at Runtime by Server.
Now IWebrowser::get_Document() retrieve IHtmlDocument2 interface and manaully parse the HTML page to reach your INPUT box and put you value into it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I searched for my problem and found other who had it, but didn't find an answer.
I am getting "LNK2001: unresolved External Symbol" in my MFC Dialog Box Program. Here is my situation:
The unresolved symbol is a CString that belongs to my Edit Control. It is declared as a Public variable in my main dialog class in "dialog1.h". Now this is being used within a static member function (in the same class) which is declared in "dialog1.h" (The function is a Seperate Thread being called by AfxBeginThread() from "dialog1.cpp". The actually Function however is in "dialog2.cpp". The CString is being used within this function in "dialog2.cpp". Both "dialog1.cpp" and "dialog2.cpp" have includes for "dialog1.h", so I do not see the reason why this is happening.
I thought of making this CString external, but I am not sure how to do it when it is a member of a class.
Rundown:
CString Variable: Declared in dialog1.h and initialized in dialog2.cpp
static member function: declared in dialog1.h and initialized in dialog2.cpp
Static member function is called from dialog1.cpp using AfxBeginThread() API.
If anyone has any suggesstions that would be great.
|
|
|
|