/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.  */
char* mxmlSaveAllocString(mxml_node_t *node, mxml_save_cb_t cb)
/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.  */
char* mxmlSaveAllocString(mxml_node_t *node, mxml_save_cb_t cb)
{
  int	bytes;
  char	*s;
  size_t bs = 8192;
  s = malloc(bs);
  bytes = mxmlSaveString(node, s, bs, cb);
  if (bytes <= 0) {
	  free(s);
    return (NULL);
  }
  if (bytes < (int)bs - 1)
  {
    return s;
  }
  free(s);
  if ((s = malloc(bytes + 1)) == NULL) {
    return (NULL);
  }
  mxmlSaveString(node, s, bytes + 1, cb);
  return (s);
}