Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE301366258@probe-2.acclaim-euro.net> From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: Bitmap Loading Problem Date: Tue, 4 May 1999 11:27:52 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1460.8) Content-Type: text/plain Reply-To: djgpp AT delorie DOT com Denis Lamarche writes: >buffer=create_bitmap(320,200); >buffer=load_bitmap("c:\\flc\\rm1t10.pcx", pal); //Or any 320x200x256 The create_bitmap() call is redundant, because you straight away assign a different value to the same pointer when you call load_bitmap(). The problem is that you are loading multiple bitmaps but never freeing any of them: you need a destroy_bitmap() to get rid of every single bitmap object that you create, not just one at the end of your program. General style point: beware of hardcoded file paths: this is a pretty sure way to create problems when someone tries to run your program on a different machine. > return 69; What on earth? C programs traditionally return zero for success, or non-zero on failure (the defines EXIT_SUCCESS and EXIT_FAILURE can be used for this). Breaking that convention will cause trouble for any shells that use the exit code. Pavlos suggested: > buffer=load_bitmap(.....) > blit(...) > free(buffer); Right theory, wrong practice. You cannot free() a bitmap: use destroy_bitmap() instead. As written, this code is a bad memory leak, and a potential crash in some situations. Shawn Hargreaves.