Implement reallocArray.
diff --git a/ndn-cpp/c/util/DynamicUCharArray.c b/ndn-cpp/c/util/DynamicUCharArray.c
index ac1e451..83016ce 100644
--- a/ndn-cpp/c/util/DynamicUCharArray.c
+++ b/ndn-cpp/c/util/DynamicUCharArray.c
@@ -8,6 +8,21 @@
char *ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length)
{
- // TODO: implement.
- return "ndn_DynamicUCharArray_reallocArray: realloc function pointer not supplied";
+ if (!self->realloc)
+ return "ndn_DynamicUCharArray_reallocArray: realloc function pointer not supplied";
+
+ // See if double is enough.
+ unsigned int newLength = self->length * 2;
+ if (length > newLength)
+ // The needed length is much greater, so use it.
+ newLength = length;
+
+ unsigned char *newArray = (*self->realloc)(self->array, newLength);
+ if (!newArray)
+ return "ndn_DynamicUCharArray_reallocArray: realloc failed";
+
+ self->array = newArray;
+ self->length = newLength;
+
+ return 0;
}
\ No newline at end of file