title: How to concat byte arrays in C
body: <p>My current concat function:</p>
  
  <pre><code>char* concat(char* a, int a_size,
               char* b, int b_size) {
      char* c = malloc(a_size + b_size);
      memcpy(c, a,            a_size);
      memcpy(c + a_size, b,   b_size);
      free(a);
      free(b);
      return c;
  }
  </code></pre>
  
  <p>But this used extra memory. Is it possible to append two byte arrays using <code>realloc</code> without making extra memory space?</p>
  
  <p>Like:</p>
  
  <pre><code>void append(char* a, int a_size, char* b, int b_size)
  ...
  
  char* a = malloc(2);
  char* b = malloc(2);
  
  void append(a, 2, b, 2);
  //The size of a will be 4.
  </code></pre>