-static int combine_diff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
-{
- struct combine_diff_state *priv = priv_;
- int i;
- for (i = 0; i < nbuf; i++) {
- if (mb[i].ptr[mb[i].size-1] != '\n') {
- /* Incomplete line */
- priv->remainder = realloc(priv->remainder,
- priv->remainder_size +
- mb[i].size);
- memcpy(priv->remainder + priv->remainder_size,
- mb[i].ptr, mb[i].size);
- priv->remainder_size += mb[i].size;
- continue;
- }
-
- /* we have a complete line */
- if (!priv->remainder) {
- consume_line(priv, mb[i].ptr, mb[i].size);
- continue;
- }
- priv->remainder = realloc(priv->remainder,
- priv->remainder_size +
- mb[i].size);
- memcpy(priv->remainder + priv->remainder_size,
- mb[i].ptr, mb[i].size);
- consume_line(priv, priv->remainder,
- priv->remainder_size + mb[i].size);
- free(priv->remainder);
- priv->remainder = NULL;
- priv->remainder_size = 0;
- }
- return 0;
-}
-