From: Radical NetSurfer Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro392 NOT HAPPY! Date: Mon, 26 Jun 2000 19:18:14 -0400 Message-ID: <1voflssugapr9b1s31ip0ce5l28ij9ep1q@4ax.com> References: X-Newsreader: Forte Agent 1.8/32.548 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.202.134.143 X-Original-NNTP-Posting-Host: 216.202.134.143 X-Trace: 26 Jun 2000 19:20:43 -0400, 216.202.134.143 Lines: 73 X-Original-NNTP-Posting-Host: 64.31.79.51 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Mon, 26 Jun 2000 18:58:36 GMT, Damian Yerrick wrote: >On Mon, 26 Jun 2000 09:26:09 -0400, Radical NetSurfer > wrote: >>I finally decided to download a try out the new W.I.P.... >> compiling my project in 3.1.2. --> 383,488 bytes >> 3.9.2. --> 610,816 >> DIFFERENCE: 227,328 >> >>WHY? is this? > >Allegro 3.9.x is designed for portability while retaining speed. >To shrink executables, strip and compress them with UPX. > http://upx.tsx.org/ I'll look into this....thanks. >>Problem 1: >>In 3.1.2: >>I have something like: >>BITMAP *a_bmp=NULL; >>a_bmp = create_bmp(z, q); >> >>NOW: what is the proper way to determine if 'a_bmp' is still >>un-assigned (NULL) or actually in use, SUCH THAT a >>proper call to 'destroy_bmp()' works.... >>Apparently, calling destroy_bmp() crashes if the pointer is >>actually unassigned.... > >It crashes because the pointer points to garbage. Whenever you free >memory, it's safest to zero the pointer immediately afterwords.. > >BITMAP *foo; > >foo = create_bitmap(w, h); >/* ... */ >destroy_bitmap(foo); >foo = NULL; > >free()-type functions typically do nothing if passed a null pointer. >I just read through .../allegro/src/graphics.c, and it works the same >way. YES! I know about this; but it got totally passed me! I've had this problem in C++ before; and I'm compiling as 'C' now so I wasn't thinking... >>Problem 2: >> >>In 3.1.2: I wish to be able to call a single function, which will >> either load in an image to a bitmap, >> or >> simply just create an empty bitmap, >> and return..... >> >> I want to call this function several times, and EACH time >>REPLACING the contents of the Bitmap, with the NEW >>image (raster).... >> Can someone PLEASE offer some suggestions how this >> might be accomplished? > >Whenever you want to load in a new bitmap, simply call >destroy_bitmap(bmp) first. YES! I did manage to get this part working as well! after the above problem was solved, other things fell into place. Again, thanks for you help. It really gave me inspiration to not give up... :-) http://members.tripod.com/~RadSurfer/