|
hi friends,
i got Different Problem.
i created one Dll(win32 application). i create one project and put main().
#include "ini.hpp"
int main()
{
char *cp,*cp1;
Config Objcon("../","rrr.ini");
Section objsec = Objcon["server"];
cp=objsec["ip"];
cp1=objsec["port"];
cout<
|
|
|
|
|
bujji_bec wrote: char *cp,*cp1;
bujji_bec wrote: delete []cp; // this one giving problem
delete []cp1; // -----------do----------
Use
delete cp;<br />
delete cp1;
Maxwell Chen
|
|
|
|
|
i tried that one and also used Free also. i am Getting Same problem
b.raju
-- modified at 1:47 Monday 22nd May, 2006
|
|
|
|
|
bujji_bec wrote: int main()
{
char *cp,*cp1;
Config Objcon("../","rrr.ini");
Section objsec = Objcon["server"];
cp=objsec["ip"];
cp1=objsec["port"];
cout<<cp<<"\n"<<"cp1;
delete []cp;="" this="" one="" giving="" problem
delete="" []cp1;="" -----------do----------
}<="" blockquote="">
bujji_bec wrote: i am Getting Same problem
According to the code in the original post, Section::operator [] (LPCTSTR token) allocates some buffer internally. The implementation inside this operator matters how memory is released (by delete ).
Do you mind posting the body of Section::operator [] (LPCTSTR) ??
Maxwell Chen
|
|
|
|
|
Why do you repost your question again ? What was the problem with the answers we gave you here[^] ?
I explained you that you cannot allocate memory in the dll and release it in your program. And furthermore, you don't give any information about what you do in the dll.
What is this class Config ?
Cédric Moonen
Software developer
Charting control
-- modified at 5:43 Friday 19th May, 2006
And also, this is the wrong forum.
|
|
|
|
|
hi friend,
acutally in dll, i am Reading .ini Files. passing Strings or Char pointer and also retrieving Strings or char pointer.finally i delete that one. that is my problem.
sudha
-- modified at 1:45 Monday 22nd May, 2006
|
|
|
|
|
bujji_bec wrote: int main()
{
char *cp,*cp1;
Config Objcon("../","rrr.ini");
Section objsec = Objcon["server"];
cp=objsec["ip"];
cp1=objsec["port"];
cout<<cp<<"\n"<<"cp1;
delete []cp;="" this="" one="" giving="" problem
delete="" []cp1;="" -----------do----------
}
in="" the="" program="" output="" coming="" correct.="" but="" delete="" its="" memory="" issues.<="" blockquote="">
I'm assuming that your Config object is defined in your DLL? That being the case, your memory is being allocated in the DLL's memoryspace, and you are trying to delete it from the application's memory space. This will cause an exception and will crash your application.
To avoid this, you have 2 options:
1) Add a method to your Config class to clean up memory it allocates. This will basically turn it into a factory for the objects it creates (what is made in the factory is also deleted in the factory).
2) Use Boost's/TR1's shared_ptr class to wrap your pointers. This will prevent this problem completely without you needing to call delete at all. Note that to do this, you should modify your DLL to return shared_ptrs.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
He asked this question already some time ago and the answer was the same as yours.
Anyway, the point is that it leads to an interesting discussion about this fact that the program will crash if you release the memory allocated in your dll from your exe. It appears that the problem arise only when both projects link to different run-time libraries.
the discussion starts here[^].
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Ah, so he did. Strange why someone would ask the exact same question 2 days in a row. Most of the answers in the previous thread were accurate enough to tell him not to do it that way.
There are many issues that factor in when someone tries this (too many to list). Suffice it to say that it doesn't work far more often than it does, and in either case, it is bad practice to free memory that was allocated by another module (simply on software engineering practices).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hello friends,
I am creating edit control at run time in WTL.
i written following handler for edit control.
NOTIFY_HANDLER(2500, EN_CHANGE, OnUpdateEdit)
LRESULT OnUpdateEdit(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
but i am unable to capture change event of edit box, means this function never execute.
|
|
|
|
|
|
Hi,
What is the CCustomDraw class used for? Can anyone explain why it is specifically used? It has methods like OnItemPostPaint, OnItemPrePaint. What are these methods?
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
|
Hi Michael,
Ofcourse I read all your WTL series. One of the best that I have read.
But my question is, When do we use COwnerDraw and when do we use CCustomDraw ?
Thanks for taking the time to answer my question.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Ownerdraw is for when you want to draw the whole thing, like a customised button. Custom draw only works with some controls, such as ListView. Basically, if the control sends NM_CUSTOMDRAW notifications, you can use Customdraw with it.
Steve S
Developer for hire
|
|
|
|
|
hello friends i have 3 edit boxes in dialog.
i want to apply Undo management on these controls.
can someone help me.
Thanks
|
|
|
|
|
I want to Create another Application with CreatProcess API, when my Windows Service will be started. Problem is that Application's WM_PAINT is not called.Anybody, can tell me
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
CreateProcess(L"D:\\TestingApplication\\DialogTest\\Debug\\DialogTest.exe",
0,0,0,false, CREATE_DEFAULT_ERROR_MODE,0,0,&siStartupInfo,&piProcessInfo);
Musharraf Hussain
|
|
|
|
|
I have a situation where a Frame window creates another FrameWindow. Now, both these windows should run on the same thread. How do achieve this?
The second window may not be a frame window but it should derive from the CWindowImpl class with CFrameWinTraits .
Any ideas gurus?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
A window is run on the thread that creates it, so just create the window - instantiate an object and call the Create method.
Steve S
Developer for hire
|
|
|
|
|
Hello friends,
I want to use outlook express in my vc++ project to send email.
when i will try to send email then outlook send mail dialog box should open.
we only need to show outlook dialog box with attached file
to the user. after that it is up to the user to send email or not
|
|
|
|
|
Does it have something to do with ATL, WTL or STL ? If not, this is the wrong forum.
For your question, look for Outlook Automation (on google for example), it can be helpfull.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
hi!
i want to display one text file in Dev studio by adding one COM add-in.
Any body help/guid me to write the COM Add-in in VC++.
thanks
shankatenugu.
|
|
|
|
|
See the following where you can find out how to create the addins for the VC++
here
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
Hi All
I am writing a component using ATL.
One of the method from the component accept a pointer to a structure. This structure definition is in other header file.
[id(3), helpstring("method get_StreamMediaType")] HRESULT get_StreamMediaType([in,out] AM_MEDIA_TYPE* pVal);
AM_MEDIA_TYPE present in 'strmif.h' file.
When I am trying to compile the project it gives me error in IDL file as
.\DSMediaInfoServices.idl(24) : error MIDL2025 : syntax error : expecting a type specification near "AM_MEDIA_TYPE"
.\DSMediaInfoServices.idl(24) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Thanks in Advance.
Amar
-- modified at 9:25 Thursday 11th May, 2006
|
|
|
|
|
I think you need to add header file in the component so that idl can understand what is AM_MEDIA_TYPE
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
-- modified at 1:03 Friday 12th May, 2006
|
|
|
|