Mail Archives: djgpp/1998/04/28/06:15:36
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 -