      int totallen;
      
      if (!output)
      {
	 totallen = len + 1;
	 output = malloc(totallen);
	 memcpy(output, buf, totallen - 1);
	 output[totallen] = '\0';
      }
      else
      {
	 totallen = strlen(output) + len + 1;
	 output = realloc(output, totallen);
	 memcpy(output + totallen, buf, totallen - 1);
	 output[totallen] = '\0';
      }

      memset(buf, '\0', sizeof(buf));
   }

