In BinaryXmlEncoder, use DynamicUCharVector.
diff --git a/ndn-cpp/encoding/binary-xml-encoder.hpp b/ndn-cpp/encoding/binary-xml-encoder.hpp
index 6373466..fc5d451 100644
--- a/ndn-cpp/encoding/binary-xml-encoder.hpp
+++ b/ndn-cpp/encoding/binary-xml-encoder.hpp
@@ -8,7 +8,7 @@
#include <vector>
#include "../common.hpp"
-#include "../c/util/ndn_realloc.h"
+#include "../util/dynamic-uchar-vector.hpp"
#include "../c/encoding/binary-xml-encoder.h"
namespace ndn {
@@ -22,9 +22,8 @@
* Initialize the base ndn_BinaryXmlEncoder struct with an initial array of 16 bytes. Use simpleRealloc.
*/
BinaryXmlEncoder()
+ : output_(16)
{
- const unsigned int initialLength = 16;
- ndn_BinaryXmlEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
}
/**
@@ -32,8 +31,10 @@
*/
ptr_lib::shared_ptr<std::vector<unsigned char> > getOutput()
{
- return ptr_lib::shared_ptr<std::vector<unsigned char> >(new std::vector<unsigned char>(output.array, output.array + offset));
+ return output_.get();
}
+
+ DynamicUCharVector output_;
};
}
diff --git a/ndn-cpp/key-chain.cpp b/ndn-cpp/key-chain.cpp
index c2a10ff..1da6f9d 100644
--- a/ndn-cpp/key-chain.cpp
+++ b/ndn-cpp/key-chain.cpp
@@ -106,7 +106,7 @@
if ((error = ndn_encodeBinaryXmlData(&dataStruct, &signedFieldsBeginOffset, &signedFieldsEndOffset, &encoder)))
throw std::runtime_error(ndn_getErrorString(error));
- digestSha256(encoder.output.array + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
+ digestSha256(&encoder.getOutput()->front() + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
}
void KeyChain::sign