Safe practices for dealing with MidiBuffer


Hi all, i’m buidling a MIDI VST plugin that should let pass Midi data in and add a lot of MIDI CC to its output.
I need to automate via VST some plugin that does not have a full VST parameter implementation and rely on MIDI CC only to automate its parameters (all XILS stuff and Tassmann i.e. ).
So i’ve built a test version that do this with one parameter only.
This is my process block.

void StiXctrlAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
    buffer.clear(); // clear audio buffer
    MidiMessage m; 
    int8 cc00Val = *cc00; //get cc00 VST parameter value

    if (cc00Val != cc00TempVal) // generate a new cc00 Controller Event only if cc00 value is changed
        m = MidiMessage::controllerEvent(1, 0, cc00Val);
        midiMessages.addEvent(m, midiMessages.getLastEventTime());
    cc00TempVal = cc00Val; // store cc00 value in a temp variable for the if statement above

Now i wonder if this is a good way to deal with MidiBuffer (i’m not using any Iterator but i simply add MIDI CC Events to the incoming MIDI stream).
Ideally the plugin will have a lot of parameters (780 parameters) each one generating a particular MIDI CC on a particular MIDI channel.

thanks and all the best