Added DynamicUCharArray
diff --git a/Makefile.am b/Makefile.am
index 0761bfe..2a5ea63 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@
ndn-cpp/encoding/BinaryXMLStructureDecoder.hpp \
ndn-cpp/encoding/BinaryXMLWireFormat.cpp ndn-cpp/encoding/BinaryXMLWireFormat.hpp \
ndn-cpp/encoding/WireFormat.cpp ndn-cpp/encoding/WireFormat.hpp \
+ ndn-cpp/util/DynamicUCharArray.c ndn-cpp/util/DynamicUCharArray.h \
ndn-cpp/util/ndn_memory.c ndn-cpp/util/ndn_memory.h
test_encode_decode_interest_SOURCES = test/test-encode-decode-interest.cpp
diff --git a/ndn-cpp/util/DynamicUCharArray.c b/ndn-cpp/util/DynamicUCharArray.c
new file mode 100644
index 0000000..9cb53e7
--- /dev/null
+++ b/ndn-cpp/util/DynamicUCharArray.c
@@ -0,0 +1,13 @@
+/*
+ * Author: Jeff Thompson
+ *
+ * BSD license, See the LICENSE file for more information.
+ */
+
+#include "ndn_memory.h"
+#include "DynamicUCharArray.h"
+
+char *ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length)
+{
+ return "ndn_DynamicUCharArray_reallocArray: realloc function pointer not supplied";
+}
\ No newline at end of file
diff --git a/ndn-cpp/util/DynamicUCharArray.h b/ndn-cpp/util/DynamicUCharArray.h
new file mode 100644
index 0000000..aaa26c1
--- /dev/null
+++ b/ndn-cpp/util/DynamicUCharArray.h
@@ -0,0 +1,52 @@
+/*
+ * Author: Jeff Thompson
+ *
+ * BSD license, See the LICENSE file for more information.
+ */
+
+#ifndef NDN_DYNAMICUCHARARRAY_H
+#define NDN_DYNAMICUCHARARRAY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ndn_DynamicUCharArray {
+ unsigned char *array;
+ unsigned int length;
+ unsigned char (*realloc)(unsigned char *array, unsigned int length);
+};
+
+static inline void ndn_DynamicUCharArray_init
+ (struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length, unsigned char (*reallocFunction)(unsigned char *, unsigned int))
+{
+ self->array = array;
+ self->length = length;
+ self->realloc = reallocFunction;
+}
+
+char *ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length);
+
+static inline char *ndn_DynamicUCharArray_ensureLength(struct ndn_DynamicUCharArray *self, unsigned int length)
+{
+ if (self->length >= length)
+ return 0;
+
+ return ndn_DynamicUCharArray_reallocArray(self, length);
+}
+
+static inline char *ndn_DynamicUCharArray_set
+ (struct ndn_DynamicUCharArray *self, unsigned char *value, unsigned int valueLength, unsigned int offset)
+{
+ char *error;
+ if (error = ndn_DynamicUCharArray_ensureLength(self, valueLength + offset))
+ return error;
+ ndn_memcpy(self->array + offset, value, valueLength);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+