From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Error in BCD Date: Tue, 28 Apr 1998 09:33:37 +0200 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 50 Message-ID: <35458651.47AB02AF@LSTM.Ruhr-UNI-Bochum.De> References: <35448FC4 DOT 62833427 AT gmx DOT net> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Bjorn De Meyer wrote: > > On Mon, 27 Apr 1998, Lennart Poettering wrote: > > > I think i have found a heavy error in BCD (The only CDROM-library for > > DJGPP): BCD doesn't alloc anough memory for its track-list: > > it will write intro memory as long as this error is not fixed. this will > > cause break downs of programs written with bcd on places nobody expects. > > > > int "bcd_get_audio_info" you will find the following code: (roundabout > > line 460) > > > > tracks = calloc(num_tracks, sizeof(Track)); [...] > > you can fix this - it is not elegant, i know - with the following change > > tracks = calloc(num_tracks+1, sizeof(Track)); > > > > than everything works fine.... > > Or if you are sure that tracks[0] is never used do a > > tracks--; > > This will decrement the pointer to point > one adress before the allocated memory starts, making 1 a valid lower > value, but disabling the use of Track[0]. I hope this is more elegant. I don't think so. You will probably forget to say free(++tracks); sooner or later and blow mallocs() internal lists. This may give funny results at occasions seemingly totally unrelated to the free() statement, and some hours of frustration. Rather give a damn about the overhead... -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************