Added ndn_realloc
diff --git a/ndn-cpp/c/util/ndn_realloc.c b/ndn-cpp/c/util/ndn_realloc.c
new file mode 100644
index 0000000..397834b
--- /dev/null
+++ b/ndn-cpp/c/util/ndn_realloc.c
@@ -0,0 +1,12 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <stdlib.h>
+#include "ndn_realloc.h"
+
+unsigned char *ndn_realloc(unsigned char *array, unsigned int length)
+{
+ return (unsigned char *)realloc(array, length);
+}
diff --git a/ndn-cpp/c/util/ndn_realloc.h b/ndn-cpp/c/util/ndn_realloc.h
new file mode 100644
index 0000000..db9470d
--- /dev/null
+++ b/ndn-cpp/c/util/ndn_realloc.h
@@ -0,0 +1,26 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_NDN_REALLOC_H
+#define NDN_NDN_REALLOC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Wrap the C stdlib realloc to convert to/from void * to unsigned char *.
+ * This can be used by ndn_DynamicUCharArray_init.
+ * @param array the allocated array buffer to realloc
+ * @param length the length for the new array buffer
+ * @return the new allocated array buffer
+ */
+unsigned char *ndn_realloc(unsigned char *array, unsigned int length);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ndn-cpp/encoding/BinaryXMLEncoder.hpp b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
index a879963..2ae5196 100644
--- a/ndn-cpp/encoding/BinaryXMLEncoder.hpp
+++ b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
@@ -6,8 +6,8 @@
#ifndef NDN_BINARYXMLENCODER_HPP
#define NDN_BINARYXMLENCODER_HPP
-#include <cstdlib>
#include <vector>
+#include "../c/util/ndn_realloc.h"
#include "../c/encoding/BinaryXMLEncoder.h"
namespace ndn {
@@ -23,18 +23,7 @@
BinaryXMLEncoder()
{
const unsigned int initialLength = 16;
- ndn_BinaryXMLEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, simpleRealloc);
- }
-
- /**
- * Wrap the C stdlib realloc to convert to/from void * to unsigned char *.
- * @param array the allocated array buffer to realloc
- * @param length the length for the new array buffer
- * @return the new allocated array buffer
- */
- static unsigned char *simpleRealloc(unsigned char *array, unsigned int length)
- {
- return (unsigned char *)realloc(array, length);
+ ndn_BinaryXMLEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
}
/**