Sign in to follow this  

malloc() problem

This topic is 4354 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

I don't think anybody can help me with this as I don't think I can explain it properly. But maybe somebody has had a similar problem. Anytime I try and use malloc to get a memory block the program crashes with the unhelpful "program has caused an error, an errorlog is being generated" (which never is). The thing about this is it only gives me a problem if I include local header files (ie "include.h") if I use global includes (ie <stdio.>) I don't get a problem. The other thing is if I use the debug build then I don't get a problem. I also get this problem if I try and assign a pointer address from one variable to another. Tried playing with project settings in VS6 but nothing seems to be working. Anybody ever had anything like this? I should note that if I copy the needed functions used in the headers to the source file in question the problem goes away. You would think its something in one of the other files. But those are all part of a bigger project that uses malloc without a problem.

Share this post


Link to post
Share on other sites
You have a bug in your code. It has nothing to do with the headers you include.

In fact, when you say that it crashes when you assign a pointer to another, it seems to me as if there's some chance what you're actually doing is assigning pointed-at values through bad pointers.

To debug this problem, start the program in the debugger, and put a breakpoint in the code before the failing line. Run to the breakpoint. Then use single-step (F10 for step over, F11 for step in) and examine the various values before and after each line.

Share this post


Link to post
Share on other sites

This topic is 4354 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this