Message-ID: <37DA1143.C8E47EFF@gtcom.net> From: Krogg X-Mailer: Mozilla 4.61 [en] (Win95; U) X-Accept-Language: en-US,en-GB,en,ja MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: c,allegro,coolness.... References: <37D9D699 DOT 8BFA4EF6 AT gtcom DOT net> <37DA07F7 DOT 182B297C AT hmc DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 76 Date: Sat, 11 Sep 1999 04:22:27 -0400 NNTP-Posting-Host: 12.6.67.138 X-Trace: eagle.america.net 937038313 12.6.67.138 (Sat, 11 Sep 1999 04:25:13 EDT) NNTP-Posting-Date: Sat, 11 Sep 1999 04:25:13 EDT Organization: 24hoursupport.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Nate Eldredge wrote: > > Krogg wrote: [snip] > > ===========begin snip from allegro docs=================== > > > > BITMAP *bmp; > > PALETTE pal; > > > > get_palette(pal); > > bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H); > > save_bitmap("dump.pcx", bmp, pal); > > destroy_bitmap(bmp); > > > > =============end snip from allegro docs=================== > > > > Well,I am lazy so i decided to try this instead: > > > > save_pcx("ifs.pcx",create_sub_bitmap(screen, 0, 0, SCREEN_W, > > SCREEN_H),pallete); > > > > What a shortcut!...and,it worked great! > > > > Is there anything wrong with doing stuff like this? > > I mean,it worked,but is there some reason i shouldnt > > do this kind of thing? > > It's a memory leak. `destroy_bitmap' frees the memory used to store the > bitmap, and your version makes it impossible to do that (the value of > bmp is lost, so you can't find it to destroy it). Not freeing your > resources is considered bad programming practice. If this code can only > happen once, or a small fixed number of times, it may not be a real > problem, since all your memory will be freed when the program quits. > However, if it's done repeatedly, then the program will eventually run > out of memory and die; not a good thing. > -- > > Nate Eldredge > neldredge AT hmc DOT edu Hmmm,I was wondering about that.It is only used once and then the program exits so it wont be a problem for this particular program. let me try something......Ok done.... I just added a for loop to call: save_pcx("ifs.pcx",create_sub_bitmap(screen, 0, 0, SCREEN_W,SCREEN_H),pallete); 100 times in a row to test this out.It didnt crash..I got 32 megs ram.I aint sure if this is cause win95 is providing plenty of virtual memory or what.... You probly know more that i do about it,but i am still clinging on to the idea that it works really good. Was 100 times not enough for a good test? Be Cool, Krogg. -- |"""""<`.THE PRINCE ,'>"""""""""""""""""""""""""""""""""""| | `.`/""""""\,',' my sig is too big, | |SEE HIS ( / \ \' SEE HIS but its really cool. | | FACE \/<> <>\/ SMILE | | / W \ Visit my ascii art site: | | ,'\_|||||_/`. http://www.gtcom.net/~krogg/ascii/ | | ,',' ||| `.`. krogg DOT no DOT to DOT spam AT gtcom DOT net | |____<,' TIME TO DIE `.>____Remove no.to.spam to reply____|