Change type of ndn_MetaInfo.finalBlockID to struct ndn_NameComponent.
diff --git a/ndn-cpp/c/data.h b/ndn-cpp/c/data.h
index 0990d86..61dd750 100644
--- a/ndn-cpp/c/data.h
+++ b/ndn-cpp/c/data.h
@@ -62,8 +62,7 @@
double timestampMilliseconds; /**< milliseconds since 1/1/1970. -1 for none */
ndn_ContentType type; /**< default is ndn_ContentType_DATA. -1 for none */
int freshnessSeconds; /**< -1 for none */
- unsigned char *finalBlockID; /**< pointer to pre-allocated buffer. 0 for none */
- unsigned int finalBlockIDLength; /**< length of finalBlockID. 0 for none */
+ struct ndn_NameComponent finalBlockID; /**< has a pointer to a pre-allocated buffer. 0 for none */
};
/**
@@ -74,8 +73,7 @@
(struct ndn_MetaInfo *self) {
self->type = ndn_ContentType_DATA;
self->freshnessSeconds = -1;
- self->finalBlockID = 0;
- self->finalBlockIDLength = 0;
+ ndn_NameComponent_initialize(&self->finalBlockID, 0, 0);
}
struct ndn_Data {
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index b07b7a4..2925ee6 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -100,7 +100,7 @@
return error;
if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
- (encoder, ndn_BinaryXml_DTag_FinalBlockID, metaInfo->finalBlockID, metaInfo->finalBlockIDLength)))
+ (encoder, ndn_BinaryXml_DTag_FinalBlockID, metaInfo->finalBlockID.value, metaInfo->finalBlockID.valueLength)))
return error;
// This will skip encoding if there is no key locator.
@@ -159,7 +159,7 @@
return error;
if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
- (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &metaInfo->finalBlockID, &metaInfo->finalBlockIDLength)))
+ (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &metaInfo->finalBlockID.value, &metaInfo->finalBlockID.valueLength)))
return error;
if ((error = ndn_decodeOptionalBinaryXmlKeyLocator(&signature->keyLocator, decoder)))
diff --git a/ndn-cpp/data.cpp b/ndn-cpp/data.cpp
index 0c5e7f3..387d291 100644
--- a/ndn-cpp/data.cpp
+++ b/ndn-cpp/data.cpp
@@ -48,12 +48,7 @@
metaInfoStruct.timestampMilliseconds = timestampMilliseconds_;
metaInfoStruct.type = type_;
metaInfoStruct.freshnessSeconds = freshnessSeconds_;
-
- metaInfoStruct.finalBlockIDLength = finalBlockID_.getValue().size();
- if (metaInfoStruct.finalBlockIDLength > 0)
- metaInfoStruct.finalBlockID = (unsigned char *)finalBlockID_.getValue().buf();
- else
- metaInfoStruct.finalBlockID = 0;
+ finalBlockID_.get(metaInfoStruct.finalBlockID);
}
void MetaInfo::set(const struct ndn_MetaInfo& metaInfoStruct)
@@ -61,7 +56,7 @@
timestampMilliseconds_ = metaInfoStruct.timestampMilliseconds;
type_ = metaInfoStruct.type;
freshnessSeconds_ = metaInfoStruct.freshnessSeconds;
- finalBlockID_.setValue(Blob(metaInfoStruct.finalBlockID, metaInfoStruct.finalBlockIDLength));
+ finalBlockID_.setValue(Blob(metaInfoStruct.finalBlockID.value, metaInfoStruct.finalBlockID.valueLength));
}
void Data::get(struct ndn_Data& dataStruct) const