components/prboom/mmus2mid.c
//
// TWriteByte()
//
// write one byte to the selected MIDItrack, update current position
// if track allocation exceeded, double it
// if track not allocated, initially allocate TRACKBUFFERSIZE bytes
//
// Passed pointer to Allegro MIDI structure, number of the MIDI track being
// written, and the byte to write.
//
// Returns 0 on success, MEMALLOC if a memory allocation error occurs
//
TWriteByte()
write one byte to the selected MIDItrack, update current position
if track allocation exceeded, double it
if track not allocated, initially allocate TRACKBUFFERSIZE bytes

Passed pointer to Allegro MIDI structure, number of the MIDI track being
written, and the byte to write.

Returns 0 on success, MEMALLOC if a memory allocation error occurs
TWriteByte () write one byte to the selected MIDItrack update current position if track allocation exceeded double it if track not allocated initially allocate TRACKBUFFERSIZE bytes Passed pointer to Allegro MIDI structure number of the MIDI track being written and the byte to write . Returns 0 on success MEMALLOC if a memory allocation error occurs
static int TWriteByte(MIDI *mididata, int MIDItrack, UBYTE byte)
{
  ULONG pos ;
  pos = mididata->track[MIDItrack].len;
  if (pos >= (ULONG)track[MIDItrack].alloced)
  {
    track[MIDItrack].alloced =        
      track[MIDItrack].alloced?       
        2*track[MIDItrack].alloced :
        TRACKBUFFERSIZE;
    if (!(mididata->track[MIDItrack].data =     
      realloc(mididata->track[MIDItrack].data,
              track[MIDItrack].alloced)))
      return MEMALLOC;
  }
  mididata->track[MIDItrack].data[pos] = byte;
  mididata->track[MIDItrack].len++;
  return 0;
}
static int TWriteByte ( MIDI * mididata , int MIDItrack , UBYTE byte ) { ULONG pos ; pos = mididata -> track [ MIDItrack ] . len ; if ( pos >= ( ULONG ) track [ MIDItrack ] . alloced ) { track [ MIDItrack ] . alloced = track [ MIDItrack ] . alloced ? 2 * track [ MIDItrack ] . alloced : TRACKBUFFERSIZE ; if ( ! ( mididata -> track [ MIDItrack ] . data = realloc ( mididata -> track [ MIDItrack ] . data , track [ MIDItrack ] . alloced ) ) ) return MEMALLOC ; } mididata -> track [ MIDItrack ] . data [ pos ] = byte ; mididata -> track [ MIDItrack ] . len ++ ; return 0 ; }
TWriteByte()
write one byte to the selected MIDItrack, update current position
if track allocation exceeded, double it
if track not allocated, initially allocate TRACKBUFFERSIZE bytes
TWriteByte () write one byte to the selected MIDItrack update current position if track allocation exceeded double it if track not allocated initially allocate TRACKBUFFERSIZE bytes
// double allocation // or set initial TRACKBUFFERSIZE // attempt to reallocate