|
Derek Lakin wrote:
need a fixed version
Do you have tried the fixes from Dinkumware[^]?
They also sell a STL, I think. But I have never tried that.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks for the link . Sometimes you can overlook the most obvious solutions
I'll try it out and let you know how I get on.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I tried all of the fixes and it made things worse, so I used all the fixes apart from the stream-related ones and it improved the problem drastically.
Still not all fixed though
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
What type of problems do you have? Where are you leaking memory?
For me, std::string seems sometimes to have those problems, but it has never been so bad that I have to fix it, that is, you can't see it in 'Task Manager', but VC++6 complains.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
The problems I had experienced were mainly danlging pointer errors.
Since first trying the fixes I have since removed those related to streams and have now managed to completely erradicate any errors
I'm just left now with 2 small memory leaks (1,864 bytes), which aren't STL related, and 16 resource leaks that aren't really leaks, it's just that DevPartner Studio picks them up on application exit, but they get freed when the MFC libraries are unloaded.
Thanks for your help
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
The problems I had experienced were mainly danlging pointer errors.
ahh.. BoundsChecker complaints? i'm not sure those problems are actually problems. BC complains about a lot of stuff that isn't a real problem.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
Derek Lakin wrote:
which improved resource leask but increased memory leaks
Depending on a define STLPORT will hold a chunk of memory until the progam ends to improve the speed of allocations. This will look to memory leak tooks as a real leak but it is not. There are a couple of discussions in their forum about this topic. Here is one: http://www.stlport.com/dcforum/DCForumID6/1181.html[^]
John
|
|
|
|
|
**[EDIT] Figured out how to do it myself. [/EDIT]**
Hey, I was looking at the IE Deskband Tutorial and it shows how to add a button to your deskband. But I am not sure how to add another button to this, can anyone help me out? THanks.
Here is what is in the tutorial:
TCHAR* pCaption = _T("Get Quote");<br />
int iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption);<br />
<br />
HICON hMotley = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MOTLEY));<br />
m_hImageList = ImageList_Create(16,16, ILC_COLOR16, 1, 0);<br />
int iImageIndex = ImageList_AddIcon(m_hImageList, hMotley);<br />
DestroyIcon(hMotley);<br />
::SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)m_hImageList);<br />
<br />
TBBUTTON Button;<br />
ZeroMemory((void*)&Button, sizeof(TBBUTTON));<br />
Button.idCommand = IDM_GETQUOTE;<br />
Button.fsState = TBSTATE_ENABLED;<br />
Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;<br />
Button.dwData = 0;<br />
Button.iString = iIndex;<br />
Button.iBitmap = 0;<br />
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button);<br />
|
|
|
|
|
I have a calss that have a member variable of type ofstream, I would like to initialize this variable in constructor.
MyClass
{
MyClass(ofstream& Logger) { m_Logger = Logger; }
private:
ofstream m_Logger;
}
But seems like there is no assignment operator for ofstream.
Any idea how can i do this?
|
|
|
|
|
Anonymous wrote:
MyClass<br />
{<br />
MyClass(ofstream& Logger) { m_Logger = Logger; }<br />
<br />
private:<br />
ofstream m_Logger;<br />
}
Why not using
MyClass<br />
{<br />
MyClass(ofstream& Logger) { m_Logger = Logger; }<br />
<br />
private:<br />
ofstream& m_Logger;<br />
}
instead ... Using a reference is even faster than creating a new stream...
Greeting, Ralph
|
|
|
|
|
Yep, ofstream s cannot be copied. So, you have several alternatives:
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Can anyone tell me about the easiest way to handle events that are fired from ATL dll ? I used ActiveX controls and when we developer client application in MFC, the event handling mechanism is very easy and automatically done by the framework. But this is not the case if our COM server is not an ActiveX but a dll. Can anyone point me out some sample app for sinking connection points in MFC ???
|
|
|
|
|
I have a vector of pointers vector <CPersons*> that is passed in a function by reference.
This function has access to another similar vector say m_Persons and i have to copy all entries from m_Persons to Persons
MyClass::MyFunc(vector<CPersons*>& Persons)
{
//This class has a member function vector<CPersons*> m_Persons
// i need to copy content of m_Persons into Persons
if (Persons.capacity() < Persons.size()+m_Persons.size())
Persons.resize(Persons.size()+m_Persons->size());
copy(m_Persons.begin(), m_Persons.end(), Persons.begin() );
}
but since this is a vector of pointer, my understanding is that anytime re-allocation of
destination vector Persons is needed, all these pointer would become invalid.
Is my understanding correct?
If yes, is this best of way doing it. If no, please advise how to attempt such problem.
|
|
|
|
|
this is probably ok. your understanding is incorrect - you will end up with two vectors containing the list of pointers. the only thing you need to be careful of is who does the clean up i.e. make sure the pointed-to objects don't get destroyed twice.
your resizing test is wrong though. capacity() returns the amount of space *allocated*, not necessarily *used*. you can just do:
<br />
Persons.resize( m_Persons.size() ) ;<br />
your misunderstanding is probably this: if you resize a vector, the memory used to store that vector's elements may be moved i.e. the memory used to store your pointers may change but not the pointers themselves.
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.2 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Anonymous wrote:
anytime re-allocation of
destination vector Persons is needed, all these pointer would become invalid
No. They get copied, but still point to the same chunk of memory containing the person-object.
But who is responsible to cleaning up, e.g. calling 'delete'?
Using smart pointer can help you here - but NEVER EVER use std::auto_ptr!!!!
Try the shared_ptr from www.boost.org[^], it uses reference counting to delete the obect it points to when the last ptr pointing to it goes out of scope.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I have a vector of pointers like
vector<cperson*> Persons
This vector is passed to method func by reference
This func has another vector of CPerson* m_Persons and i have to copy all entries from m_Persons to Persons
I am doing it in following way
func(vector<cperson*>& Persons)
{
if (Persons.capacity() < Persons.size()+m_Persons->size())
Persons.resize(Persons.size()+m_Persons->size());
copy(m_Persons.begin(), m_Persons.end(), Persons.begin() );
}
but seems to me doing this way i an losing some references CPerson* in Persons
Is this right way of doing this?
Am i in problem because anytime vector need to reallocated memory, i am loosing all previous references?
PS: Please oppologize any typos as i am only trying to give the concetp
|
|
|
|
|
What i wanted to say in first two lines is
I have a vector of pointers of a class Persons
vector<persons*>
|
|
|
|
|
Has anyone here used CMimeMessage to compose or decode a MIME encoded message and attachments etc?
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
Yep, I did. But just some small tests, if and how it works. No real app.
|
|
|
|
|
I want to use CMimeMessage and other ATL7 classes to create and decode MIME messages and attachments.For example, I want to create a MIME message with a single attachment like:
IMultiLanguage *pLang = NULL;
CoInitialize(NULL);
CMimeMessage msg(pLang);
if(msg.SetSender("visualcdev@hotmail.com"))
if(msg.SetDisplayName("My custom mime message to be displayed in a string"))
{
msg.SetPriority(ATL_MIME_LOW_PRIORITY );
msg.SetSubject("custom subject");
msg.AddText(_T("hello world from a test message you should also end a string like this."));
msg.AddRecipient(_T("amitdey@softhome.net"),"amitdey@softhome.net",0);
msg.AttachFile("C:\\scantastic.bmp");
}
But when I view the contents of the message, by writing it to a file, the message is not a MIME formatted message( I cannot see the headers or anything.
DWORD dwWritten;
DWORD Ret = WriteFile(hFile,&msg,sizeof(msg),&dwWritten,NULL);
message does not have proper MIME headers.How can I use CMimeMessage to create/modify MIME messages?
Thanks.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
Hi,
the first part is OK and works. Your problem is in the WriteFile phase. You cannot use the WriteFile as you did, because then you will just save the CMimeMessage class as is in memory. And because CMimeMessage nearly stores only pointers to other classes (body, attachements etc.) you'll see nothing usefull.
The correct way how can you save the message is:
msg.WriteData( hFile, &overlapped );
This method makes more processing, stores also the aggregated classes etc and makes a mime message for you.
Hope this helps
|
|
|
|
|
Yes, the Overlapped i/o did it. Thanks. From the samples I have seen, CMimeMessage is more for composing and sending messages, what about translating/decoding messages and attachments.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
Also, if I have a mime-formatted message as an IStream, can I attach it anyway to a CMimeMessage and then use the classes to parse info? How?
TIA.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|
|
I don't think that the CMimeMessage is ready for parsing. It was designed for creating the message & sending.
For parsing it will be required to use another class or build your own.
|
|
|
|
|
Interesting. I can see that the ATL7 CMimeMessage creates correct Outlook Express mail files. i.e. .eml format.
Yes, I guess I would have to write a class myself. But it should not be too difficult, esp with all decoding code in the ATL classes that I can use.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - PocketPC New menu
Office addin
|
|
|
|