|
No , i am not allocating the memory
many times i have just done it once
its not the cause
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
vikas amin wrote: many times i have just done it once
ohh, in that case why don't you use CString or stl::string class... is there any problem using them
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
vikas amin wrote: In my class the code is as
char *m_FileName;
m_FileName=new char[strlen(FileName)];
strcpy(m_FileName,FileName);
are you calling this code in Constructor or some where else... You have delete memory every time you allocate it.. it seems you allocating memory many times but deallocating only one time, at time of destruction.
better use CString class instead of new
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: are you calling this code in Constructor or some where else... You have delete memory every time you allocate it.. it seems you allocating memory many times but deallocating only one time, at time of destruction.
Good point using the example code I gave earlier the fix would be to add this to the MyClass class
//constructor
MyClass() { mystring = NULL; } // could also create a constructor that assigns the string
~MyClass() { if (mystring) delete[] mystring; }
SetMyString(const char* const newString)
{
if (mystring) delete[] mystring;
mystring = new char*[strlen(newString)+1];
strcpy(mystring, newString);
}
|
|
|
|
|
|
So, you still get the crash apparently... Are the two files (the header and the source file) big ? If not, post them completely, we will try to help you. Cause with the suggestion we gave you, it should work, so the problem is probably elsewhere: you probably write outside some other boundary that overwrite on the m_FileName address (thus corrupting some internal information at the begining of the array).
|
|
|
|
|
Ok i will just docment the files
and send u .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello !
I have a problem in my solution which use extensively STL.
When we remove pointer from list<> in A.dll to B.dll [OK]
When we put back from B.dll to A.dll [ACCESS VIOLATION]
We have : prim.dll, env.dll and app.exe (multithread)
[prim.dll] Shape* newLine();
[app.exe] list<Shape*> obj;
[env.dll] list<Shape*> undo;
The senario :
[create line] Shape* line=newLine(); obj.push_back(line);
[delete line] obj.remove(line); undo.push_back(line);
[undo delete] obj.push_back(undo.front());
[problem ] obj.front()=0xfeeefeee
Object was never delete until now, but we got an invalid pointer. Your idea and comments would be very helpful.
Thanks.
|
|
|
|
|
Did you accidentally mix-up the calls? Maybe you deleted it during one call because you swapped two lines of source?
Or you have a , where a ; should be?
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Thank you for your comments. I would scan for , and ; misplaced.
Sovann.
|
|
|
|
|
I'm not new to programming, I am however new to Visual Studio C++. I'm adapting an old engine to use some newer libraries. I know the code in the new libraries is fine as we use it in several other projects, however whenever I try to call some functions in this one project I get LNK2019 errors.
A sample of the message is:
st_model.obj : error LNK2019: unresolved external symbol "public: static void __fastcall Graphics::NodeBin::QueueForDelete(class Graphics::Node *)" (?QueueForDelete@NodeBin@Graphics@@SIXPAVNode@2@@Z) referenced in function "public: void __thiscall Tool::Model::Free(void)" (?Free@Model@Tool@@QAEXXZ)
with the source code generating the error :
st_model.cpp
<br />
#include "gr_node_bin.h"<br />
<br />
namespace Tool<br />
{<br />
void anyfunction()<br />
{<br />
<br />
::Graphics::NodeBin::QueueForDelete(NULL);
<br />
}<br />
}
the QueueForDelete interface
gr_node_bin.h
namespace Graphics<br />
{<br />
class NodeBin<br />
{<br />
<br />
public:<br />
<br />
static void QueueForDelete(Graphics::Node *node);<br />
<br />
};<br />
}
the QueueForDelete implementation
gr_node_bin.cpp
namespace Graphics<br />
{<br />
<br />
void NodeBin::QueueForDelete(Graphics::Node *node)<br />
{<br />
}<br />
<br />
}
I've tried several different calling conventions within the project but they don't seem to have any effect.
Can anyone help me here? Are there any decent online references to tell me what the symbols mean?
|
|
|
|
|
Nevermind. One of the dependancies wasn't ticked in the project settings. Don't you just love when something that looks so complex turns out to be so simple.
|
|
|
|
|
I dont know the solution of ur problem
but
the symbols are generated by the compiler
which is know as NAME MANGLING .
It is essential in C++ as there are overloaded
functions , and the compiler have to differenciate
them .so it generate a different name for it .
could not find much detials u see this site
http://www.cs.virginia.edu/~cs216/labs/lab6/Linking/MS%20Visual%20C++%20and%20Assembly.htm
http://www.google.co.in/search?hl=en&q=vc+compiler+changes+the+name+of+function&btnG=Google+Search&meta=
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Thanks. Now that you mention it name mangling rings a bell.
|
|
|
|
|
You can get your 'unmangled' names declared this way:
<br />
extern "C" {<br />
#include "gr_node_bin.h"<br />
}<br />
In other words, when you include header in CPP file for that of library written in C, you need to let compiler know now to make your OBJ look for UN-mangled names, since they will be UN-mangled in the other C-style library.
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Does somebody have same problem with menu ownerdrawing?
http://zero.clarionlife.net/Images/problem.jpg
|
|
|
|
|
If you have MSDN installed there is a sample project called ctrltest.
Try to search for it in the CD or hard disk (if you have it on disk).
It is a good example for "OwnerDrawn" (not me;P) menus for starters.
Hope this will help.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Hello, everyone,
We developed a programe, when our client take tese.
In his computer , when he push a button (the button is about Version Information), the program will crush.
But in our computer, the environment is same as his, but everything gones well.
He pass the error report image to us, from the image, we
can see the following informations:
AppName: our program, ModeName: mfc71u.dll
ModVer:7.10.30770 offset: 00033b40
Who can tell me how can we re-appear such crush
by the error report.
Thanks a lot!
|
|
|
|
|
Give the customer release DLLs or EXEs (whatever they are) with Debug Strings at the places where you might think crash has happened and then check the outputs.
|
|
|
|
|
int errcode = GetLastError() ;
GflPower
|
|
|
|
|
Hello.
Read this[^]
article.
It has saved me more than once. If you do as the article says, you can pinpoint the exact code line in the source-code, where the error occurred! (In a release build).
Kakan
|
|
|
|
|
I hope this question makes sense...
If I have a number of controls in a CView derived class, how can I get that view to pass on any messages from the controls to the view's parent window?
|
|
|
|
|
SendMessage
or
PostMessage
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Hi,
I have this code for connecting to SQL Server:
CString sql;
CDatabase m_database ;
sql.Format("DRIVER=SQL Server;SERVER=myserver;DATABASE=test;UID=administrator; PWD=admin;Trusted_Connection=No");
m_database.SetLoginTimeout(10);
m_database.SetQueryTimeout(10);
TRY{
m_database.OpenEx (sql,CDatabase::noOdbcDialog );
}
CATCH(CDBException, e){
m_database.Close();
MessageBox("Connection failed");
}
END_CATCH
I am connecting to a remote sql server. This code works fine if I'm connected in the network and i was able to catch the Exception, however, when I disconnect the host pc from network, an unknown exception was thrown. "Unknown software exception (0x0000409)..." . Is there any way to catch this exception ? It also happen when I mispelled the server name.
Mar Solero Jr.
|
|
|
|
|
I have an CSpinButtonCtrl autobuddied with an EditBox. How can I get the CSpinButtonCtrl to inc/dec in 2's as I only want even numbers to appear in the EditBox and by default the CSpinButtonCtrl inc/decs in 1's.
Follows is a stripped down version of my implementation
In the .h file I declare
class C_VIEW : public CDialog<br />
{<br />
public:<br />
C_VIEW(CWnd* pParent = NULL);
CSpinButtonCtrl m_spinner;<br />
};
In the .cpp file I implement
void C_VIEW::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_SPINNER, m_spinner);<br />
}
In the initialisation routine I set the min/max range
BOOL C_VIEW::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
m_spinner.SetRange(0, 100);<br />
}
the value is saved when the dialog box is closed.
void C_VIEW::OnOK()
{<br />
save_all_values();<br />
CDialog::OnOK();<br />
}
I thought of rounding the value as it is saved, but that is not elegant and would misguide a user who had selected an odd value.
cgb143
|
|
|
|