Why does my prog just stop?

This is a discussion on Why does my prog just stop? within the Windows Programming forums, part of the Platform Specific Boards category; Why does this program just stop right after checkpoint 3 comes up? I know it has somthing to do with ...

Hmm... not sure why'd it'd just stop truthfully, but here's a couple of things I notice:

Your buffer is an array. It appears you reallocate the buffer [array]. If you're reallocating a buffer, is there a possibility that the pointer to the buffer might change? (Since you're setting it, probably.) If you set buffer to a new value, the calling function will have no knowledge of this!

How does QuickWrite know the size of the buffer it's writing? What do cp() and ReallocOrFree() do?

The first time through, would the second part of that not be:
-1 - 0x4000 - 1 < 0x4000... which is always true?

Finally, indent. Indent, please! It makes reading easier, trust me.

And what's wrong with using gotos? (In that sense) Yes, his code could be rewritten to not use them, but he'd have to free the resources in each error check, would he not? Terribly tedious. Adding other things such as file handles, or allocated memory, would be harder to add.

2. If you had decent indentation, then it would be obvious that having goto's out of and if/else chain is pointless, because that is where you're going anyway, so there really is no point in banging on about it.

3. ReallocOrFree
What you pass to this first is NOT something you alloced, but a local array on the stack.
Just sit back and wait for the boom.