fix the safe function behavior
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 9e92ae2..72c2dac 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -24,7 +24,6 @@
 #include "tinyxml2.h"

 

 #if 1

-	#include <cstdarg>

 	#include <cstdio>

 	#include <cstdlib>

 	#include <new>

@@ -998,7 +997,7 @@
 void XMLAttribute::SetAttribute( int v )

 {

 	char buf[BUF_SIZE];

-	TIXML_SNPRINTF( buf, BUF_SIZE-1, "%d", v );	

+	TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v );	

 	value.SetStr( buf );

 }

 

@@ -1534,10 +1533,10 @@
 			int len = -1;

 			int expand = 1000;

 			while ( len < 0 ) {

-				len = vsnprintf_s( accumulator.Mem(), accumulator.Capacity(), accumulator.Capacity()-1, format, va );

+				len = vsnprintf_s( accumulator.Mem(), accumulator.Capacity(), _TRUNCATE, format, va );

 				if ( len < 0 ) {

-					accumulator.PushArr( expand );

 					expand *= 3/2;

+					accumulator.PushArr( expand );

 				}

 			}

 			char* p = buffer.PushArr( len ) - 1;