title: Buffer (unsigned char *) concatenation in C
body: <p>Probably a very easy question for a C developer, however, I'm new to C and I didn't fully grasp all the concepts behind it yet. So, right now, I use this code to concatenate 2 buffers (audioData and silenceData) and then use them to stream some audio:</p>
  
  <pre><code>typedef struct {
      unsigned char * data;
      UInt32 size;    
  } SoundData;
  
      SoundData audioData;
              audioData.data = audioFiles[currentSoundDataIndex];
              audioData.size = audioFilesSize[currentSoundDataIndex];
  
      SoundData silenceData;
                  silenceData.size = 44100*2*fabs(silenceDuration-0.049f);
                  silenceData.data = malloc(silenceData.size);        
                  memset(silenceData.data,0,silenceData.size);
  
                  //beat data
      SoundData beatData;
                  beatData.size = (audioData.size + silenceData.size);    
                  beatData.data = malloc(beatData.size);
  
                  for (int i=0; i&lt;audioData.size; i++) {
                      beatData.data[i] = audioData.data[i];
                  }
  
                  for (int i=audioData.size; i&lt;beatData.size; i++) {
                      beatData.data[i] = silenceData.data[i-audioData.size];
                  }
  </code></pre>
  
  <p>This works fine, but I have the feeling that there must be a better way to do it, some built in function maybe?</p>