Added DynamicUCharVector.
diff --git a/Makefile.am b/Makefile.am
index 0983f68..49092a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,7 +58,8 @@
ndn-cpp/encoding/wire-format.cpp ndn-cpp/encoding/wire-format.hpp \
ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/tcp-transport.h ndn-cpp/transport/tcp-transport.cpp ndn-cpp/transport/tcp-transport.hpp \
ndn-cpp/transport/transport.cpp ndn-cpp/transport/transport.hpp \
- ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp
+ ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp \
+ ndn-cpp/util/dynamic-uchar-vector.cpp ndn-cpp/util/dynamic-uchar-vector.hpp
bin_test_encode_decode_interest_SOURCES = tests/test-encode-decode-interest.cpp
bin_test_encode_decode_interest_LDADD = libndn-cpp.la libndn-c.la
diff --git a/Makefile.in b/Makefile.in
index b653284..d52990c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -159,7 +159,8 @@
ndn-cpp/encoding/wire-format.lo \
ndn-cpp/transport/tcp-transport.lo \
ndn-cpp/transport/transport.lo \
- ndn-cpp/transport/udp-transport.lo
+ ndn-cpp/transport/udp-transport.lo \
+ ndn-cpp/util/dynamic-uchar-vector.lo
libndn_cpp_la_OBJECTS = $(am_libndn_cpp_la_OBJECTS)
PROGRAMS = $(bin_PROGRAMS)
am_bin_test_encode_decode_data_OBJECTS = \
@@ -498,7 +499,8 @@
ndn-cpp/encoding/wire-format.cpp ndn-cpp/encoding/wire-format.hpp \
ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/tcp-transport.h ndn-cpp/transport/tcp-transport.cpp ndn-cpp/transport/tcp-transport.hpp \
ndn-cpp/transport/transport.cpp ndn-cpp/transport/transport.hpp \
- ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp
+ ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp \
+ ndn-cpp/util/dynamic-uchar-vector.cpp ndn-cpp/util/dynamic-uchar-vector.hpp
bin_test_encode_decode_interest_SOURCES = tests/test-encode-decode-interest.cpp
bin_test_encode_decode_interest_LDADD = libndn-cpp.la libndn-c.la
@@ -708,6 +710,14 @@
ndn-cpp/transport/$(DEPDIR)/$(am__dirstamp)
ndn-cpp/transport/udp-transport.lo: ndn-cpp/transport/$(am__dirstamp) \
ndn-cpp/transport/$(DEPDIR)/$(am__dirstamp)
+ndn-cpp/util/$(am__dirstamp):
+ @$(MKDIR_P) ndn-cpp/util
+ @: > ndn-cpp/util/$(am__dirstamp)
+ndn-cpp/util/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) ndn-cpp/util/$(DEPDIR)
+ @: > ndn-cpp/util/$(DEPDIR)/$(am__dirstamp)
+ndn-cpp/util/dynamic-uchar-vector.lo: ndn-cpp/util/$(am__dirstamp) \
+ ndn-cpp/util/$(DEPDIR)/$(am__dirstamp)
libndn-cpp.la: $(libndn_cpp_la_OBJECTS) $(libndn_cpp_la_DEPENDENCIES) $(EXTRA_libndn_cpp_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) -rpath $(libdir) $(libndn_cpp_la_OBJECTS) $(libndn_cpp_la_LIBADD) $(LIBS)
@@ -804,6 +814,8 @@
-rm -f ndn-cpp/encoding/*.lo
-rm -f ndn-cpp/transport/*.$(OBJEXT)
-rm -f ndn-cpp/transport/*.lo
+ -rm -f ndn-cpp/util/*.$(OBJEXT)
+ -rm -f ndn-cpp/util/*.lo
-rm -f tests/*.$(OBJEXT)
distclean-compile:
@@ -836,6 +848,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/transport/$(DEPDIR)/tcp-transport.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/transport/$(DEPDIR)/transport.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/transport/$(DEPDIR)/udp-transport.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/util/$(DEPDIR)/dynamic-uchar-vector.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-encode-decode-data.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-encode-decode-interest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-get-async.Po@am__quote@
@@ -901,6 +914,7 @@
-rm -rf ndn-cpp/c/util/.libs ndn-cpp/c/util/_libs
-rm -rf ndn-cpp/encoding/.libs ndn-cpp/encoding/_libs
-rm -rf ndn-cpp/transport/.libs ndn-cpp/transport/_libs
+ -rm -rf ndn-cpp/util/.libs ndn-cpp/util/_libs
distclean-libtool:
-rm -f libtool config.lt
@@ -1170,6 +1184,8 @@
-rm -f ndn-cpp/encoding/$(am__dirstamp)
-rm -f ndn-cpp/transport/$(DEPDIR)/$(am__dirstamp)
-rm -f ndn-cpp/transport/$(am__dirstamp)
+ -rm -f ndn-cpp/util/$(DEPDIR)/$(am__dirstamp)
+ -rm -f ndn-cpp/util/$(am__dirstamp)
-rm -f tests/$(DEPDIR)/$(am__dirstamp)
-rm -f tests/$(am__dirstamp)
@@ -1183,7 +1199,7 @@
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf ndn-cpp/$(DEPDIR) ndn-cpp/c/$(DEPDIR) ndn-cpp/c/encoding/$(DEPDIR) ndn-cpp/c/transport/$(DEPDIR) ndn-cpp/c/util/$(DEPDIR) ndn-cpp/encoding/$(DEPDIR) ndn-cpp/transport/$(DEPDIR) tests/$(DEPDIR)
+ -rm -rf ndn-cpp/$(DEPDIR) ndn-cpp/c/$(DEPDIR) ndn-cpp/c/encoding/$(DEPDIR) ndn-cpp/c/transport/$(DEPDIR) ndn-cpp/c/util/$(DEPDIR) ndn-cpp/encoding/$(DEPDIR) ndn-cpp/transport/$(DEPDIR) ndn-cpp/util/$(DEPDIR) tests/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
@@ -1231,7 +1247,7 @@
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf ndn-cpp/$(DEPDIR) ndn-cpp/c/$(DEPDIR) ndn-cpp/c/encoding/$(DEPDIR) ndn-cpp/c/transport/$(DEPDIR) ndn-cpp/c/util/$(DEPDIR) ndn-cpp/encoding/$(DEPDIR) ndn-cpp/transport/$(DEPDIR) tests/$(DEPDIR)
+ -rm -rf ndn-cpp/$(DEPDIR) ndn-cpp/c/$(DEPDIR) ndn-cpp/c/encoding/$(DEPDIR) ndn-cpp/c/transport/$(DEPDIR) ndn-cpp/c/util/$(DEPDIR) ndn-cpp/encoding/$(DEPDIR) ndn-cpp/transport/$(DEPDIR) ndn-cpp/util/$(DEPDIR) tests/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
diff --git a/libtool b/libtool
index 0331b3e..58a4686 100755
--- a/libtool
+++ b/libtool
@@ -2,7 +2,7 @@
# libtool - Provide generalized library-building support services.
# Generated automatically by config.status (ndn-cpp) 0.5
-# Libtool was configured on host Jeffs-MacBook-Pro.local:
+# Libtool was configured on host krill.remap.ucla.edu:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
diff --git a/ndn-cpp/util/dynamic-uchar-vector.cpp b/ndn-cpp/util/dynamic-uchar-vector.cpp
new file mode 100644
index 0000000..d346494
--- /dev/null
+++ b/ndn-cpp/util/dynamic-uchar-vector.cpp
@@ -0,0 +1,31 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "dynamic-uchar-vector.hpp"
+
+using namespace std;
+
+namespace ndn {
+
+DynamicUCharVector::DynamicUCharVector(unsigned int initialLength)
+: vector_(new vector<unsigned char>(initialLength))
+{
+ ndn_DynamicUCharArray_init(this, &vector_->front(), initialLength, DynamicUCharVector::realloc);
+}
+
+unsigned char *DynamicUCharVector::realloc(struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length)
+{
+ // Because this method is private, assume there is not a problem with upcasting.
+ DynamicUCharVector *thisObject = (DynamicUCharVector *)self;
+
+ if (array != &thisObject->vector_->front())
+ // We don't expect this to ever happen. The caller didn't pass the array from this object.
+ return 0;
+
+ thisObject->vector_->reserve(length);
+ return &thisObject->vector_->front();
+}
+
+}
diff --git a/ndn-cpp/util/dynamic-uchar-vector.hpp b/ndn-cpp/util/dynamic-uchar-vector.hpp
new file mode 100644
index 0000000..f372aff
--- /dev/null
+++ b/ndn-cpp/util/dynamic-uchar-vector.hpp
@@ -0,0 +1,48 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_DYNAMIC_UCHAR_VECTOR_HPP
+#define NDN_DYNAMIC_UCHAR_VECTOR_HPP
+
+#include <vector>
+#include "../common.hpp"
+#include "../c/util/dynamic-uchar-array.h"
+
+namespace ndn {
+
+/**
+ * A DynamicUCharVector extends ndn_DynamicUCharArray to hold a shared_ptr<vector<unsigned char> > for use with
+ * C functions which need an ndn_DynamicUCharArray.
+ */
+class DynamicUCharVector : ndn_DynamicUCharArray {
+public:
+ /**
+ * Create a new DynamicUCharVector with an initial length.
+ * @param initialLength The initial size of the allocated vector.
+ */
+ DynamicUCharVector(unsigned int initialLength);
+
+ /**
+ * Get the shared_ptr to the allocated vector.
+ * @return The shared_ptr to the allocated vector.
+ */
+ const ptr_lib::shared_ptr<std::vector<unsigned char> > &get() { return vector_; }
+
+private:
+ /**
+ * Implement the static realloc function using vector reserve.
+ * @param self A pointer to this object.
+ * @param array Should be the front of the vector.
+ * @param length The new length for the vector.
+ * @return The front of the allocated vector.
+ */
+ static unsigned char *realloc(struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length);
+
+ ndn::ptr_lib::shared_ptr<std::vector<unsigned char> > vector_;
+};
+
+}
+
+#endif