Bug in NeroCMD?

vbimport

#1

I’m using Nero SDK 1.05 and one line in the NeroCMD program looks a bit strange to me. In the file WriteIsoAudio.cpp, in the first function (CBurnContext::WriteIsoAudio) there is a line:
iSize = sizeof (NERO_WRITE_CD) + (params.GetNumberOfTracks() - 1) * sizeof (NERO_AUDIO_TRACK);

If there are no tracks, the size would become smaller than sizeof( NERO_WRITE_CD). So, shouldn’t the -1 be removed ?

Cheers.


#2

If there are no tracks, the size would indeed be smaller but this does not cause any harm even though it might look a bit awkward at first sight. If you take the time to check it out, you will find that the last field of NERO_WRITE_CD strcuture is actually a one-sized array of NERO_AUDIO_TRACK. This actually means that NERO_WRITE_CD already provides us with one NERO_AUDIO_TRACK structure, so we need only allocate one less than our real requirement. The fact that there may be zero tracks, translates into a crippled NERO_WRITE_CD structure, but as there are NO tracks, NeroAPI will NEVER try to interpret nwcdTracks field.

If you remove -1, you will always allocate exactly one NERO_AUDIO_TRACK more than you need to.


#3

I see. Very strange construct indeed. Why didn’t they just make the NERO_AUDIO_TRACK a pointer instead ?


#4

Probably in order to keep everything in a single contiguous block of memory.