Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Corrail

MS VC++ Problem (Debug/Release)

This topic is 5654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! I''ve a problem with MS Visual C++. If I compile my program with Debug-config everything works fine. But if I compile it with Release-config some error occur. I think I made some mistakes at dynamic memory management. But I don''t know where! I''m using following code for allocating and deleting arrays: float* test; test = new float[anzahl]; delete[] test; This is right, isn''t it? I''m deleting every memory I allocte after using it. I''m really confused about the face that if I''m calling a void in a loop the void sometimes works fine and sometimes does mistakes. But this only happens if I compile my program with Release-config. What''s very strange too is that if I''m compiling with MS VS 6.0 no windows-error message appears but if I''m compiling with VS.NET an error message with the text "Heap-integry is incorrect" (or something like that). Any ideas?? Thanks a lot! Corrail corrail@gmx.at ICQ#59184081

Share this post


Link to post
Share on other sites
Advertisement
You're definitelely allocating and deallocating memory correctly.

But the crash may be caused by some garbage pointer somewhere. It's happened to me before, but I never bothered to fix it , I was giving up on that prject anyway...

Btw, I didn't try anything in vs.net... Only MSVC++ 6.0

[edited by - James Trotter on April 1, 2003 11:14:41 AM]

Share this post


Link to post
Share on other sites
It does look like a corrupt pointer or you are accessing outside the bounds of an array.

quote:

... I''m calling a void in a loop the void sometimes ...



I''m not totally sure what you mean by this, could you explain it a bit more (if you feel it is relevant).

Share this post


Link to post
Share on other sites
Hi guyz!

I''ve found the error!!
I''ve done this before:

char* _chrINIFileName;

int SetFileName(char* _chrIn)
{
_chrINIFileName = new char[strlen(_chrIn)];
sprintf(_chrINIFileName, "%s", _chrIn);
return -32768;
}

instead of allocating (strlen(_chrIn)+1)!!!

But thanks a lot for your help!!

Corrail
corrail@gmx.at
ICQ#59184081

Share this post


Link to post
Share on other sites
You should use std::string and std::stringstream for that sort of stuff, they aren''t susceptible to buffer overruns.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!