From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: prog fails when run twice Date: 1 Oct 2001 11:08:51 GMT Organization: Aachen University of Technology (RWTH) Lines: 25 Message-ID: <9p9is3$hlv$1@nets3.rz.RWTH-Aachen.DE> References: <5zKt7.4503$qi DOT 745588 AT news2-win DOT server DOT ntlworld DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1001934531 18111 137.226.32.75 (1 Oct 2001 11:08:51 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 1 Oct 2001 11:08:51 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Brian Smith wrote: > I have a game prog I have written in C++ and ASM. > It involves large graphics files and small 'spites like' objects. The > graphic are constructed in a mem block set up by malloc. All changes (moves > etc) are completed here then the whole file is copied to the vidoe memory. > a 'newly complied' program runs fine but when it is run again, with > compling, the 'sprite' positions are wrong (out of position). This more probably than anything else means that you are using uninitialized variables. The values from the first run are still in the same memory positions when you run it again, and they're different from those that the compiler, using the same memory, has left there. > I have checked the 'FREE' command and this matches exactly the MALLOC > allocations. Memory leaks or other malloc()/free() usage errors are quite unlikely to be the source of this problem. It looks more like your using variable fields found in freshly malloc()ed memory blocks without setting them to some definite value. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.