delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/28/06:15:36

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
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> <Pine DOT GSO DOT 3 DOT 96 DOT 980427174157 DOT 20692A-100000 AT eduserv2 DOT rug DOT ac DOT be>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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                *
*************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019