function consolidation when writing to xmlBuffer. Return error condition

* xmlIO.c xmlwriter.c: function consolidation when writing to xmlBuffer.
  Return error condition not len if xmlwriter fails writing to buffer.
diff --git a/xmlIO.c b/xmlIO.c
index 9e302ae..f30f775 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -2490,12 +2490,11 @@
 
     if (buffer == NULL) return(NULL);
 
-    ret = xmlAllocOutputBuffer(encoder);
-    if (ret != NULL) {
-        ret->context = buffer;
-        ret->writecallback = xmlBufferWrite;
-        ret->closecallback = xmlBufferClose;
-    }
+    ret = xmlOutputBufferCreateIO((xmlOutputWriteCallback)
+                                  xmlBufferWrite,
+                                  (xmlOutputCloseCallback)
+                                  xmlBufferClose,
+                                  (void *) buffer, encoder);
 
     return(ret);
 }