Browse Source

globa: Change unsigned int to size_t where it is the size of a byte array or an index/offset into it.

pull/1/head
Jeff Thompson 12 years ago
parent
commit
97223afa76
  1. 14
      ndn-cpp/c/data.h
  2. 8
      ndn-cpp/c/encoding/binary-xml-data.c
  3. 4
      ndn-cpp/c/encoding/binary-xml-data.h
  4. 30
      ndn-cpp/c/encoding/binary-xml-decoder.c
  5. 18
      ndn-cpp/c/encoding/binary-xml-decoder.h
  6. 2
      ndn-cpp/c/encoding/binary-xml-element-reader.c
  7. 10
      ndn-cpp/c/encoding/binary-xml-element-reader.h
  8. 30
      ndn-cpp/c/encoding/binary-xml-encoder.c
  9. 16
      ndn-cpp/c/encoding/binary-xml-encoder.h
  10. 6
      ndn-cpp/c/encoding/binary-xml-interest.c
  11. 4
      ndn-cpp/c/encoding/binary-xml-name.c
  12. 10
      ndn-cpp/c/encoding/binary-xml-structure-decoder.c
  13. 8
      ndn-cpp/c/encoding/binary-xml-structure-decoder.h
  14. 4
      ndn-cpp/c/forwarding-entry.h
  15. 4
      ndn-cpp/c/interest.c
  16. 16
      ndn-cpp/c/interest.h
  17. 6
      ndn-cpp/c/key.h
  18. 2
      ndn-cpp/c/name.c
  19. 10
      ndn-cpp/c/name.h
  20. 2
      ndn-cpp/c/publisher-public-key-digest.h
  21. 6
      ndn-cpp/c/transport/socket-transport.c
  22. 4
      ndn-cpp/c/transport/socket-transport.h
  23. 4
      ndn-cpp/c/transport/tcp-transport.h
  24. 4
      ndn-cpp/c/transport/udp-transport.h
  25. 4
      ndn-cpp/c/util/blob.h
  26. 2
      ndn-cpp/c/util/crypto.c
  27. 2
      ndn-cpp/c/util/crypto.h
  28. 4
      ndn-cpp/c/util/dynamic-uint8-array.c
  29. 14
      ndn-cpp/c/util/dynamic-uint8-array.h
  30. 12
      ndn-cpp/c/util/ndn_memory.c
  31. 12
      ndn-cpp/c/util/ndn_memory.h
  32. 2
      ndn-cpp/c/util/ndn_realloc.c
  33. 2
      ndn-cpp/c/util/ndn_realloc.h
  34. 2
      ndn-cpp/common.cpp
  35. 6
      ndn-cpp/data.cpp
  36. 6
      ndn-cpp/data.hpp
  37. 2
      ndn-cpp/encoding/binary-xml-decoder.hpp
  38. 2
      ndn-cpp/encoding/binary-xml-element-reader.cpp
  39. 4
      ndn-cpp/encoding/binary-xml-element-reader.hpp
  40. 4
      ndn-cpp/encoding/binary-xml-structure-decoder.hpp
  41. 8
      ndn-cpp/encoding/binary-xml-wire-format.cpp
  42. 12
      ndn-cpp/encoding/binary-xml-wire-format.hpp
  43. 8
      ndn-cpp/encoding/wire-format.cpp
  44. 18
      ndn-cpp/encoding/wire-format.hpp
  45. 2
      ndn-cpp/forwarding-entry.hpp
  46. 4
      ndn-cpp/interest.cpp
  47. 10
      ndn-cpp/interest.hpp
  48. 2
      ndn-cpp/key.hpp
  49. 22
      ndn-cpp/name.cpp
  50. 14
      ndn-cpp/name.hpp
  51. 8
      ndn-cpp/node.cpp
  52. 2
      ndn-cpp/node.hpp
  53. 2
      ndn-cpp/publisher-public-key-digest.hpp
  54. 8
      ndn-cpp/security/identity/memory-private-key-storage.cpp
  55. 6
      ndn-cpp/security/identity/memory-private-key-storage.hpp
  56. 6
      ndn-cpp/security/identity/private-key-storage.hpp
  57. 6
      ndn-cpp/sha256-with-rsa-signature.hpp
  58. 6
      ndn-cpp/transport/tcp-transport.cpp
  59. 2
      ndn-cpp/transport/tcp-transport.hpp
  60. 2
      ndn-cpp/transport/transport.cpp
  61. 2
      ndn-cpp/transport/transport.hpp
  62. 6
      ndn-cpp/transport/udp-transport.cpp
  63. 2
      ndn-cpp/transport/udp-transport.hpp
  64. 4
      ndn-cpp/util/blob.hpp
  65. 2
      ndn-cpp/util/changed-event.cpp
  66. 4
      ndn-cpp/util/dynamic-uint8-vector.cpp
  67. 4
      ndn-cpp/util/dynamic-uint8-vector.hpp
  68. 18
      ndn-cpp/util/signed-blob.hpp
  69. 2
      tests/test-encode-decode-data.cpp
  70. 2
      tests/test-get-async.cpp

14
ndn-cpp/c/data.h

@ -21,11 +21,11 @@ extern "C" {
struct ndn_Signature {
uint8_t *digestAlgorithm; /**< pointer to pre-allocated buffer. 0 for none.
* If none, default is 2.16.840.1.101.3.4.2.1 (sha-256). */
unsigned int digestAlgorithmLength; /**< length of digestAlgorithm. 0 for none */
size_t digestAlgorithmLength; /**< length of digestAlgorithm. 0 for none */
uint8_t *witness; /**< pointer to pre-allocated buffer. 0 for none. */
unsigned int witnessLength; /**< length of witness. 0 for none */
size_t witnessLength; /**< length of witness. 0 for none */
uint8_t *signature;
unsigned int signatureLength;
size_t signatureLength;
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
struct ndn_KeyLocator keyLocator;
};
@ -36,7 +36,7 @@ struct ndn_Signature {
* @param keyNameComponents The pre-allocated array of ndn_NameComponent for the keyLocator.
* @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
*/
static inline void ndn_Signature_initialize(struct ndn_Signature *self, struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) {
static inline void ndn_Signature_initialize(struct ndn_Signature *self, struct ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents) {
self->digestAlgorithm = 0;
self->digestAlgorithmLength = 0;
self->witness = 0;
@ -82,7 +82,7 @@ struct ndn_Data {
struct ndn_Name name;
struct ndn_MetaInfo metaInfo;
uint8_t *content; /**< pointer to the content */
unsigned int contentLength; /**< length of content */
size_t contentLength; /**< length of content */
};
/**
@ -95,8 +95,8 @@ struct ndn_Data {
* @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
*/
static inline void ndn_Data_initialize
(struct ndn_Data *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents,
struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents)
(struct ndn_Data *self, struct ndn_NameComponent *nameComponents, size_t maxNameComponents,
struct ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents)
{
ndn_Signature_initialize(&self->signature, keyNameComponents, maxKeyNameComponents);
ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);

8
ndn-cpp/c/encoding/binary-xml-data.c

@ -77,7 +77,7 @@ static ndn_Error encodeSignedInfo(struct ndn_Signature *signature, struct ndn_Me
if (!(metaInfo->type < 0 || metaInfo->type == ndn_ContentType_DATA)) {
// Not the default of DATA, so we need to encode the type.
uint8_t *typeBytes;
unsigned int typeBytesLength = 3;
size_t typeBytesLength = 3;
if (metaInfo->type == ndn_ContentType_ENCR)
typeBytes = "\x10\xD0\x91";
else if (metaInfo->type == ndn_ContentType_GONE)
@ -128,7 +128,7 @@ static ndn_Error decodeSignedInfo(struct ndn_Signature *signature, struct ndn_Me
return error;
uint8_t *typeBytes;
unsigned int typeBytesLength;
size_t typeBytesLength;
if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
(decoder, ndn_BinaryXml_DTag_Type, 0, &typeBytes, &typeBytesLength)))
return error;
@ -173,7 +173,7 @@ static ndn_Error decodeSignedInfo(struct ndn_Signature *signature, struct ndn_Me
}
ndn_Error ndn_encodeBinaryXmlData
(struct ndn_Data *data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset, struct ndn_BinaryXmlEncoder *encoder)
(struct ndn_Data *data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset, struct ndn_BinaryXmlEncoder *encoder)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_ContentObject)))
@ -203,7 +203,7 @@ ndn_Error ndn_encodeBinaryXmlData
}
ndn_Error ndn_decodeBinaryXmlData
(struct ndn_Data *data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset, struct ndn_BinaryXmlDecoder *decoder)
(struct ndn_Data *data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset, struct ndn_BinaryXmlDecoder *decoder)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_ContentObject)))

4
ndn-cpp/c/encoding/binary-xml-data.h

@ -27,7 +27,7 @@ extern "C" {
* @return 0 for success, else an error code.
*/
ndn_Error ndn_encodeBinaryXmlData
(struct ndn_Data *data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset, struct ndn_BinaryXmlEncoder *encoder);
(struct ndn_Data *data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset, struct ndn_BinaryXmlEncoder *encoder);
/**
* Decode the data packet as binary XML and set the fields in the data object.
@ -40,7 +40,7 @@ ndn_Error ndn_encodeBinaryXmlData
* @return 0 for success, else an error code.
*/
ndn_Error ndn_decodeBinaryXmlData
(struct ndn_Data *data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset, struct ndn_BinaryXmlDecoder *decoder);
(struct ndn_Data *data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset, struct ndn_BinaryXmlDecoder *decoder);
#ifdef __cplusplus
}

30
ndn-cpp/c/encoding/binary-xml-decoder.c

@ -34,11 +34,11 @@ static inline unsigned int unsafeGetOctet(struct ndn_BinaryXmlDecoder *self)
* @param resultOut output the parsed integer.
* @return 0 for success, else an error code, including if an element of value is not a decimal digit.
*/
static ndn_Error parseUnsignedDecimalInt(uint8_t *value, unsigned int valueLength, unsigned int *resultOut)
static ndn_Error parseUnsignedDecimalInt(uint8_t *value, size_t valueLength, unsigned int *resultOut)
{
unsigned int result = 0;
unsigned int i;
size_t i;
for (i = 0; i < valueLength; ++i) {
uint8_t digit = value[i];
if (!(digit >= '0' && digit <= '9'))
@ -125,7 +125,7 @@ ndn_Error ndn_BinaryXmlDecoder_peekDTag(struct ndn_BinaryXmlDecoder *self, unsig
unsigned int type;
unsigned int value;
unsigned int saveOffset = self->offset;
size_t saveOffset = self->offset;
ndn_Error error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &type, &value);
// Restore offset.
self->offset = saveOffset;
@ -140,7 +140,7 @@ ndn_Error ndn_BinaryXmlDecoder_peekDTag(struct ndn_BinaryXmlDecoder *self, unsig
}
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength)
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@ -160,10 +160,12 @@ ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
}
unsigned int itemType;
if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, valueLength)))
unsigned int uintValueLength;
if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, &uintValueLength)))
return error;
// Ignore itemType.
*value = self->input + self->offset;
*valueLength = (size_t)uintValueLength;
self->offset += *valueLength;
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
@ -173,7 +175,7 @@ ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength)
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
{
ndn_Error error;
int gotExpectedTag;
@ -192,18 +194,20 @@ ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
}
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength)
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
return error;
unsigned int itemType;
if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, valueLength)))
unsigned int uintValueLength;
if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, &uintValueLength)))
return error;
if (itemType != ndn_BinaryXml_UDATA)
return NDN_ERROR_item_is_not_UDATA;
*value = self->input + self->offset;
*valueLength = uintValueLength;
self->offset += *valueLength;
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
@ -213,7 +217,7 @@ ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength)
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
{
ndn_Error error;
int gotExpectedTag;
@ -235,7 +239,7 @@ ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned int *value)
{
uint8_t *udataValue;
unsigned int udataValueLength;
size_t udataValueLength;
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue, &udataValueLength)))
return error;
@ -272,7 +276,7 @@ ndn_Error ndn_BinaryXmlDecoder_readTimeMillisecondsDTagElement
{
ndn_Error error;
uint8_t *bytes;
unsigned int bytesLength;
size_t bytesLength;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes, &bytesLength)))
return error;
@ -299,10 +303,10 @@ ndn_Error ndn_BinaryXmlDecoder_readOptionalTimeMillisecondsDTagElement
return NDN_ERROR_success;
}
double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, unsigned int bytesLength)
double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, size_t bytesLength)
{
double result = 0.0;
unsigned int i;
size_t i;
for (i = 0; i < bytesLength; ++i) {
result *= 256.0;
result += (double)bytes[i];

18
ndn-cpp/c/encoding/binary-xml-decoder.h

@ -16,11 +16,11 @@ extern "C" {
struct ndn_BinaryXmlDecoder {
uint8_t *input;
unsigned int inputLength;
unsigned int offset;
size_t inputLength;
size_t offset;
};
static inline void ndn_BinaryXmlDecoder_initialize(struct ndn_BinaryXmlDecoder *self, uint8_t *input, unsigned int inputLength)
static inline void ndn_BinaryXmlDecoder_initialize(struct ndn_BinaryXmlDecoder *self, uint8_t *input, size_t inputLength)
{
self->input = input;
self->inputLength = inputLength;
@ -78,7 +78,7 @@ ndn_Error ndn_BinaryXmlDecoder_peekDTag(struct ndn_BinaryXmlDecoder *self, unsig
* and the binary data is absent
*/
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength);
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength);
/**
* Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readBinaryDTagElement.
@ -93,7 +93,7 @@ ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
* @return 0 for success, else an error code, including if allowNull is 0 and the binary data is absent
*/
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength);
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength);
/**
* Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
@ -106,7 +106,7 @@ ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
* @return 0 for success, else an error code, including an error if not the expected tag, or if the item is not UDATA.
*/
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength);
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength);
/**
* Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readUDataDTagElement.
@ -120,7 +120,7 @@ ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
* @return 0 for success, else an error code.
*/
ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength);
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength);
/**
* Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
@ -177,14 +177,14 @@ ndn_Error ndn_BinaryXmlDecoder_readOptionalTimeMillisecondsDTagElement
* @param bytesLength the length of bytes
* @return the result
*/
double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, unsigned int bytesLength);
double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, size_t bytesLength);
/**
* Set the offset into the input, used for the next read.
* @param self pointer to the ndn_BinaryXmlDecoder struct
* @param offset the new offset
*/
static inline void ndn_BinaryXmlDecoder_seek(struct ndn_BinaryXmlDecoder *self, unsigned int offset)
static inline void ndn_BinaryXmlDecoder_seek(struct ndn_BinaryXmlDecoder *self, size_t offset)
{
self->offset = offset;
}

2
ndn-cpp/c/encoding/binary-xml-element-reader.c

@ -7,7 +7,7 @@
#include "binary-xml-element-reader.h"
ndn_Error ndn_BinaryXmlElementReader_onReceivedData
(struct ndn_BinaryXmlElementReader *self, uint8_t *data, unsigned int dataLength)
(struct ndn_BinaryXmlElementReader *self, uint8_t *data, size_t dataLength)
{
// Process multiple objects in the data.
while(1) {

10
ndn-cpp/c/encoding/binary-xml-element-reader.h

@ -19,7 +19,7 @@ extern "C" {
* will be passed to onReceivedElement.
*/
struct ndn_ElementListener {
void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength); /**< see ndn_ElementListener_initialize */
void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength); /**< see ndn_ElementListener_initialize */
};
/**
@ -29,7 +29,7 @@ struct ndn_ElementListener {
* self is the pointer to this ndn_ElementListener struct. See ndn_BinaryXmlElementReader_onReceivedData.
*/
static inline void ndn_ElementListener_initialize
(struct ndn_ElementListener *self, void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength))
(struct ndn_ElementListener *self, void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength))
{
self->onReceivedElement = onReceivedElement;
}
@ -45,7 +45,7 @@ struct ndn_BinaryXmlElementReader {
struct ndn_BinaryXmlStructureDecoder structureDecoder;
int usePartialData;
struct ndn_DynamicUInt8Array partialData;
unsigned int partialDataLength;
size_t partialDataLength;
};
/**
@ -58,7 +58,7 @@ struct ndn_BinaryXmlElementReader {
*/
static inline void ndn_BinaryXmlElementReader_initialize
(struct ndn_BinaryXmlElementReader *self, struct ndn_ElementListener *elementListener,
uint8_t *buffer, unsigned int bufferLength, uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, unsigned int))
uint8_t *buffer, size_t bufferLength, uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, size_t))
{
self->elementListener = elementListener;
ndn_BinaryXmlStructureDecoder_initialize(&self->structureDecoder);
@ -75,7 +75,7 @@ static inline void ndn_BinaryXmlElementReader_initialize
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlElementReader_onReceivedData
(struct ndn_BinaryXmlElementReader *self, uint8_t *data, unsigned int dataLength);
(struct ndn_BinaryXmlElementReader *self, uint8_t *data, size_t dataLength);
#ifdef __cplusplus
}

30
ndn-cpp/c/encoding/binary-xml-encoder.c

@ -24,7 +24,7 @@ enum {
* @param arrayLength the length of the array
* @return 0 for success, else an error code
*/
static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, uint8_t *array, unsigned int arrayLength)
static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, uint8_t *array, size_t arrayLength)
{
ndn_Error error;
if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + arrayLength)))
@ -39,7 +39,7 @@ static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, uint8_t *array, u
/**
* Return the number of bytes to encode a header of value x.
*/
static unsigned int getNHeaderEncodingBytes(unsigned int x)
static size_t getNHeaderEncodingBytes(unsigned int x)
{
// Do a quick check for pre-compiled results.
if (x <= ENCODING_LIMIT_1_BYTE)
@ -49,7 +49,7 @@ static unsigned int getNHeaderEncodingBytes(unsigned int x)
if (x <= ENCODING_LIMIT_3_BYTES)
return 3;
unsigned int nBytes = 1;
size_t nBytes = 1;
// Last byte gives you TT_VALUE_BITS.
// Remainder each gives you REGULAR_VALUE_BITS.
@ -67,7 +67,7 @@ static unsigned int getNHeaderEncodingBytes(unsigned int x)
* @param array
* @param length
*/
static void reverse(uint8_t *array, unsigned int length)
static void reverse(uint8_t *array, size_t length)
{
if (length == 0)
return;
@ -121,10 +121,10 @@ static ndn_Error encodeReversedUnsignedDecimalInt(struct ndn_BinaryXmlEncoder *s
* @return 0 for success, else an error code
*/
static ndn_Error reverseBufferAndInsertHeader
(struct ndn_BinaryXmlEncoder *self, unsigned int startOffset, unsigned int type)
(struct ndn_BinaryXmlEncoder *self, size_t startOffset, unsigned int type)
{
unsigned int nBufferBytes = self->offset - startOffset;
unsigned int nHeaderBytes = getNHeaderEncodingBytes(nBufferBytes);
size_t nBufferBytes = self->offset - startOffset;
size_t nHeaderBytes = getNHeaderEncodingBytes(nBufferBytes);
ndn_Error error;
if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + nHeaderBytes)))
return error;
@ -177,7 +177,7 @@ ndn_Error ndn_BinaryXmlEncoder_encodeTypeAndValue(struct ndn_BinaryXmlEncoder *s
return NDN_ERROR_header_type_is_out_of_range;
// Encode backwards. Calculate how many bytes we need.
unsigned int nEncodingBytes = getNHeaderEncodingBytes(value);
size_t nEncodingBytes = getNHeaderEncodingBytes(value);
ndn_Error error;
if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + nEncodingBytes)))
return error;
@ -190,7 +190,7 @@ ndn_Error ndn_BinaryXmlEncoder_encodeTypeAndValue(struct ndn_BinaryXmlEncoder *s
value >>= ndn_BinaryXml_TT_VALUE_BITS;
// Rest of value goes into preceding bytes, 7 bits per byte. (Zero top bit is "more" flag.)
unsigned int i = self->offset + nEncodingBytes - 2;
size_t i = self->offset + nEncodingBytes - 2;
while (value != 0 && i >= self->offset) {
self->output->array[i] = (value & ndn_BinaryXml_REGULAR_VALUE_MASK);
value >>= ndn_BinaryXml_REGULAR_VALUE_BITS;
@ -217,7 +217,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeElementClose(struct ndn_BinaryXmlEncoder *se
return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength)
ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_BLOB, valueLength)))
@ -229,7 +229,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint
return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
@ -244,7 +244,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder
return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength)
ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_UDATA, valueLength)))
@ -256,7 +256,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uin
return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
@ -274,7 +274,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder
ndn_Error ndn_BinaryXmlEncoder_writeUnsignedDecimalInt(struct ndn_BinaryXmlEncoder *self, unsigned int value)
{
// First write the decimal int (to find out how many bytes it is), then shift it forward to make room for the header.
unsigned int startOffset = self->offset;
size_t startOffset = self->offset;
ndn_Error error;
if ((error = encodeReversedUnsignedDecimalInt(self, value)))
@ -307,7 +307,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeAbsDoubleBigEndianBlob(struct ndn_BinaryXmlE
splitAbsDouble(value, &hi32, &lo32);
// First encode the big endian backwards, then reverseBufferAndInsertHeader will reverse it.
unsigned int startOffset = self->offset;
size_t startOffset = self->offset;
ndn_Error error;
while (lo32 != 0) {

16
ndn-cpp/c/encoding/binary-xml-encoder.h

@ -20,7 +20,7 @@ extern "C" {
*/
struct ndn_BinaryXmlEncoder {
struct ndn_DynamicUInt8Array *output; /**< A pointer to a ndn_DynamicUInt8Array which receives the encoded output */
unsigned int offset; /**< the offset into output.array for the next encoding */
size_t offset; /**< the offset into output.array for the next encoding */
};
/**
@ -70,7 +70,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeElementClose(struct ndn_BinaryXmlEncoder *se
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength);
ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
/**
* Write an element start header using DTAG with the tag to self->output, then the blob, then an element close.
@ -81,7 +81,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength);
ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeBlobDTagElement.
@ -92,7 +92,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
{
if (value && valueLength > 0)
return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value, valueLength);
@ -107,7 +107,7 @@ static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength);
ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
/**
* Write an element start header using DTAG with the tag to self->output, then the UDATA value, then an element close.
@ -118,7 +118,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uin
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength);
ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeUDataDTagElement.
@ -129,7 +129,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalUDataDTagElement
(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
{
if (value && valueLength > 0)
return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value, valueLength);
@ -166,7 +166,7 @@ ndn_Error ndn_BinaryXmlEncoder_writeUnsignedDecimalIntDTagElement(struct ndn_Bin
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalUnsignedDecimalIntDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, int value)
{
if (value >= 0)
return ndn_BinaryXmlEncoder_writeUnsignedDecimalIntDTagElement(self, tag, (unsigned int)value);
return ndn_BinaryXmlEncoder_writeUnsignedDecimalIntDTagElement(self, tag, (size_t)value);
else
return NDN_ERROR_success;
}

6
ndn-cpp/c/encoding/binary-xml-interest.c

@ -21,7 +21,7 @@ static ndn_Error encodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXml
return error;
// TODO: Do we want to order the components (except for ANY)?
unsigned int i;
size_t i;
for (i = 0; i < exclude->nEntries; ++i) {
struct ndn_ExcludeEntry *entry = &exclude->entries[i];
@ -61,7 +61,7 @@ static ndn_Error decodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXml
if (gotExpectedTag) {
// Component
uint8_t *component;
unsigned int componentLen;
size_t componentLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
return error;
@ -97,7 +97,7 @@ static ndn_Error decodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXml
if (gotExpectedTag) {
// Skip the Bloom and treat it as Any.
uint8_t *value;
unsigned int valueLen;
size_t valueLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Bloom, 0, &value, &valueLen)))
return error;

4
ndn-cpp/c/encoding/binary-xml-name.c

@ -15,7 +15,7 @@ ndn_Error ndn_encodeBinaryXmlName(struct ndn_Name *name, struct ndn_BinaryXmlEnc
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_Name)))
return error;
unsigned int i;
size_t i;
for (i = 0; i < name->nComponents; ++i) {
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
(encoder, ndn_BinaryXml_DTag_Component, name->components[i].value, name->components[i].valueLength)))
@ -45,7 +45,7 @@ ndn_Error ndn_decodeBinaryXmlName(struct ndn_Name *name, struct ndn_BinaryXmlDec
break;
uint8_t *component;
unsigned int componentLen;
size_t componentLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
return error;

10
ndn-cpp/c/encoding/binary-xml-structure-decoder.c

@ -31,7 +31,7 @@ static inline void startHeader(struct ndn_BinaryXmlStructureDecoder *self)
}
ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
(struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, unsigned int inputLength)
(struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, size_t inputLength)
{
if (self->gotElementEnd)
// Someone is calling when we already got the end.
@ -64,14 +64,14 @@ ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
continue;
}
unsigned int startingHeaderLength = self->headerLength;
size_t startingHeaderLength = self->headerLength;
while (1) {
if (self->offset >= inputLength) {
// We can't get all of the header bytes from this input. Save in headerBuffer.
if (self->headerLength > sizeof(self->headerBuffer))
return NDN_ERROR_cannot_store_more_header_bytes_than_the_size_of_headerBuffer;
self->useHeaderBuffer = 1;
unsigned int nNewBytes = self->headerLength - startingHeaderLength;
size_t nNewBytes = self->headerLength - startingHeaderLength;
ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
return NDN_ERROR_success;
@ -89,7 +89,7 @@ ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
// Copy the remaining bytes into headerBuffer.
if (self->headerLength > sizeof(self->headerBuffer))
return NDN_ERROR_cannot_store_more_header_bytes_than_the_size_of_headerBuffer;
unsigned int nNewBytes = self->headerLength - startingHeaderLength;
size_t nNewBytes = self->headerLength - startingHeaderLength;
ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
// Use a local decoder just for the headerBuffer.
@ -132,7 +132,7 @@ ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
return NDN_ERROR_findElementEnd_unrecognized_header_type;
}
else if (self->state == ndn_BinaryXmlStructureDecoder_READ_BYTES) {
unsigned int nRemainingBytes = inputLength - self->offset;
size_t nRemainingBytes = inputLength - self->offset;
if (nRemainingBytes < self->nBytesToRead) {
// Need more.
self->offset += nRemainingBytes;

8
ndn-cpp/c/encoding/binary-xml-structure-decoder.h

@ -16,10 +16,10 @@ extern "C" {
struct ndn_BinaryXmlStructureDecoder {
int gotElementEnd; /**< boolean */
unsigned int offset;
size_t offset;
int level;
int state;
unsigned int headerLength;
size_t headerLength;
int useHeaderBuffer; /**< boolean */
// 10 bytes is enough to hold an encoded header with a type and a 64 bit value.
uint8_t headerBuffer[10];
@ -44,14 +44,14 @@ void ndn_BinaryXmlStructureDecoder_initialize(struct ndn_BinaryXmlStructureDecod
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
(struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, unsigned int inputLength);
(struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, size_t inputLength);
/**
* Set the offset into the input, used for the next read.
* @param self pointer to the ndn_BinaryXmlStructureDecoder struct
* @param offset the new offset
*/
static inline void ndn_BinaryXmlStructureDecoder_seek(struct ndn_BinaryXmlStructureDecoder *self, unsigned int offset)
static inline void ndn_BinaryXmlStructureDecoder_seek(struct ndn_BinaryXmlStructureDecoder *self, size_t offset)
{
self->offset = offset;
}

4
ndn-cpp/c/forwarding-entry.h

@ -20,7 +20,7 @@ extern "C" {
*/
struct ndn_ForwardingEntry {
uint8_t *action; /**< pointer to pre-allocated buffer. 0 for none. */
unsigned int actionLength; /**< length of action. 0 for none. */
size_t actionLength; /**< length of action. 0 for none. */
struct ndn_Name prefix;
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
int faceId; /**< -1 for none. */
@ -36,7 +36,7 @@ struct ndn_ForwardingEntry {
* @param maxPrefixNameComponents the number of elements in the allocated prefixNameComponents array
*/
static inline void ndn_ForwardingEntry_initialize
(struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, unsigned int maxPrefixNameComponents)
(struct ndn_ForwardingEntry *self, struct ndn_NameComponent *prefixNameComponents, size_t maxPrefixNameComponents)
{
self->action = 0;
self->actionLength = 0;

4
ndn-cpp/c/interest.c

@ -20,7 +20,7 @@ int ndn_Exclude_compareComponents(struct ndn_NameComponent *component1, struct n
int ndn_Exclude_matches(struct ndn_Exclude *self, struct ndn_NameComponent *component)
{
unsigned int i;
size_t i;
for (i = 0; i < self->nEntries; ++i) {
if (self->entries[i].type == ndn_Exclude_ANY) {
struct ndn_ExcludeEntry *lowerBound = 0;
@ -28,7 +28,7 @@ int ndn_Exclude_matches(struct ndn_Exclude *self, struct ndn_NameComponent *comp
lowerBound = self->entries + (i - 1);
// Find the upper bound, possibly skipping over multiple ANY in a row.
unsigned int iUpperBound;
size_t iUpperBound;
struct ndn_ExcludeEntry *upperBound = 0;
for (iUpperBound = i + 1; iUpperBound < self->nEntries; ++iUpperBound) {
if (self->entries[iUpperBound].type == ndn_Exclude_COMPONENT) {

16
ndn-cpp/c/interest.h

@ -34,7 +34,7 @@ struct ndn_ExcludeEntry {
* @param component the pre-allocated buffer for the component value, only used if type is ndn_Exclude_COMPONENT
* @param componentLength the number of bytes in value, only used if type is ndn_Exclude_COMPONENT
*/
static inline void ndn_ExcludeEntry_initialize(struct ndn_ExcludeEntry *self, ndn_ExcludeType type, uint8_t *component, unsigned int componentLength)
static inline void ndn_ExcludeEntry_initialize(struct ndn_ExcludeEntry *self, ndn_ExcludeType type, uint8_t *component, size_t componentLength)
{
self->type = type;
ndn_NameComponent_initialize(&self->component, component, componentLength);
@ -45,8 +45,8 @@ static inline void ndn_ExcludeEntry_initialize(struct ndn_ExcludeEntry *self, nd
*/
struct ndn_Exclude {
struct ndn_ExcludeEntry *entries; /**< pointer to the array of entries. */
unsigned int maxEntries; /**< the number of elements in the allocated entries array */
unsigned int nEntries; /**< the number of entries in the exclude, 0 for no exclude */
size_t maxEntries; /**< the number of elements in the allocated entries array */
size_t nEntries; /**< the number of entries in the exclude, 0 for no exclude */
};
/**
* Initialize an ndn_Exclude struct with the entries array.
@ -54,7 +54,7 @@ struct ndn_Exclude {
* @param entries the pre-allocated array of ndn_ExcludeEntry
* @param maxEntries the number of elements in the allocated entries array
*/
static inline void ndn_Exclude_initialize(struct ndn_Exclude *self, struct ndn_ExcludeEntry *entries, unsigned int maxEntries)
static inline void ndn_Exclude_initialize(struct ndn_Exclude *self, struct ndn_ExcludeEntry *entries, size_t maxEntries)
{
self->entries = entries;
self->maxEntries = maxEntries;
@ -102,8 +102,8 @@ struct ndn_Interest {
int answerOriginKind; /**< -1 for none */
int scope; /**< -1 for none */
double interestLifetimeMilliseconds; /**< milliseconds. -1.0 for none */
uint8_t *nonce; /**< pointer to pre-allocated buffer. 0 for none */
unsigned int nonceLength; /**< length of nonce. 0 for none */
uint8_t *nonce; /**< pointer to pre-allocated buffer. 0 for none */
size_t nonceLength; /**< length of nonce. 0 for none */
};
/**
@ -116,8 +116,8 @@ struct ndn_Interest {
* @param maxExcludeEntries the number of elements in the allocated excludeEntries array
*/
static inline void ndn_Interest_initialize
(struct ndn_Interest *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents,
struct ndn_ExcludeEntry *excludeEntries, unsigned int maxExcludeEntries)
(struct ndn_Interest *self, struct ndn_NameComponent *nameComponents, size_t maxNameComponents,
struct ndn_ExcludeEntry *excludeEntries, size_t maxExcludeEntries)
{
ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
self->minSuffixComponents = -1;

6
ndn-cpp/c/key.h

@ -31,7 +31,7 @@ typedef enum {
*/
struct ndn_KeyLocator {
ndn_KeyLocatorType type; /**< -1 for none */
uint8_t *keyData; /**< A pointer to a pre-allocated buffer for the key data as follows:
uint8_t *keyData; /**< A pointer to a pre-allocated buffer for the key data as follows:
* If type is ndn_KeyLocatorType_KEY, the key data.
* If type is ndn_KeyLocatorType_CERTIFICATE, the certificate data.
* If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST, the publisher public key digest.
@ -39,7 +39,7 @@ struct ndn_KeyLocator {
* If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST, the publisher issuer key digest.
* If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST, the publisher issuer certificate digest.
*/
unsigned int keyDataLength; /**< The length of keyData. */
size_t keyDataLength; /**< The length of keyData. */
struct ndn_Name keyName; /**< The key name (only used if type is ndn_KeyLocatorType_KEYNAME.) */
ndn_KeyNameType keyNameType; /**< The type of data for keyName, -1 for none. (only used if type is ndn_KeyLocatorType_KEYNAME.) */
};
@ -51,7 +51,7 @@ struct ndn_KeyLocator {
* @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
*/
static inline void ndn_KeyLocator_initialize
(struct ndn_KeyLocator *self, struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) {
(struct ndn_KeyLocator *self, struct ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents) {
self->type = (ndn_KeyLocatorType)-1;
self->keyData = 0;
self->keyDataLength = 0;

2
ndn-cpp/c/name.c

@ -14,7 +14,7 @@ int ndn_Name_match(struct ndn_Name *self, struct ndn_Name *name)
return 0;
// Check if at least one of given components doesn't match.
unsigned int i;
size_t i;
for (i = 0; i < self->nComponents; ++i) {
struct ndn_NameComponent *selfComponent = self->components + i;
struct ndn_NameComponent *nameComponent = name->components + i;

10
ndn-cpp/c/name.h

@ -16,7 +16,7 @@ extern "C" {
*/
struct ndn_NameComponent {
uint8_t *value; /**< pointer to the pre-allocated buffer for the component value */
unsigned int valueLength; /**< the number of bytes in value */
size_t valueLength; /**< the number of bytes in value */
};
/**
@ -25,7 +25,7 @@ struct ndn_NameComponent {
* @param value the pre-allocated buffer for the component value
* @param valueLength the number of bytes in value
*/
static inline void ndn_NameComponent_initialize(struct ndn_NameComponent *self, uint8_t *value, unsigned int valueLength)
static inline void ndn_NameComponent_initialize(struct ndn_NameComponent *self, uint8_t *value, size_t valueLength)
{
self->value = value;
self->valueLength = valueLength;
@ -36,8 +36,8 @@ static inline void ndn_NameComponent_initialize(struct ndn_NameComponent *self,
*/
struct ndn_Name {
struct ndn_NameComponent *components; /**< pointer to the array of components. */
unsigned int maxComponents; /**< the number of elements in the allocated components array */
unsigned int nComponents; /**< the number of components in the name */
size_t maxComponents; /**< the number of elements in the allocated components array */
size_t nComponents; /**< the number of components in the name */
};
/**
@ -46,7 +46,7 @@ struct ndn_Name {
* @param components the pre-allocated array of ndn_NameComponent
* @param maxComponents the number of elements in the allocated components array
*/
static inline void ndn_Name_initialize(struct ndn_Name *self, struct ndn_NameComponent *components, unsigned int maxComponents)
static inline void ndn_Name_initialize(struct ndn_Name *self, struct ndn_NameComponent *components, size_t maxComponents)
{
self->components = components;
self->maxComponents = maxComponents;

2
ndn-cpp/c/publisher-public-key-digest.h

@ -19,7 +19,7 @@ extern "C" {
*/
struct ndn_PublisherPublicKeyDigest {
uint8_t *publisherPublicKeyDigest; /**< pointer to pre-allocated buffer. 0 for none */
unsigned int publisherPublicKeyDigestLength; /**< length of publisherPublicKeyDigest. 0 for none */
size_t publisherPublicKeyDigestLength; /**< length of publisherPublicKeyDigest. 0 for none */
};
/**

6
ndn-cpp/c/transport/socket-transport.c

@ -67,7 +67,7 @@ ndn_Error ndn_SocketTransport_connect(struct ndn_SocketTransport *self, ndn_Sock
return NDN_ERROR_success;
}
ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, unsigned int dataLength)
ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, size_t dataLength)
{
if (self->socketDescriptor < 0)
return NDN_ERROR_SocketTransport_socket_is_not_open;
@ -115,7 +115,7 @@ ndn_Error ndn_SocketTransport_receiveIsReady(struct ndn_SocketTransport *self, i
}
ndn_Error ndn_SocketTransport_receive
(struct ndn_SocketTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytesOut)
(struct ndn_SocketTransport *self, uint8_t *buffer, size_t bufferLength, size_t *nBytesOut)
{
if (self->socketDescriptor < 0)
return NDN_ERROR_SocketTransport_socket_is_not_open;
@ -124,7 +124,7 @@ ndn_Error ndn_SocketTransport_receive
if ((nBytes = recv(self->socketDescriptor, buffer, bufferLength, 0)) == -1)
return NDN_ERROR_SocketTransport_error_in_recv;
*nBytesOut = (unsigned int)nBytes;
*nBytesOut = (size_t)nBytes;
return NDN_ERROR_success;
}

4
ndn-cpp/c/transport/socket-transport.h

@ -50,7 +50,7 @@ ndn_Error ndn_SocketTransport_connect(struct ndn_SocketTransport *self, ndn_Sock
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, unsigned int dataLength);
ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, size_t dataLength);
/**
* Check if there is data ready on the socket to be received with ndn_SocketTransport_receive.
@ -71,7 +71,7 @@ ndn_Error ndn_SocketTransport_receiveIsReady(struct ndn_SocketTransport *self, i
* @return 0 for success, else an error code.
*/
ndn_Error ndn_SocketTransport_receive
(struct ndn_SocketTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes);
(struct ndn_SocketTransport *self, uint8_t *buffer, size_t bufferLength, size_t *nBytes);
/**
* Close the socket.

4
ndn-cpp/c/transport/tcp-transport.h

@ -45,7 +45,7 @@ static inline ndn_Error ndn_TcpTransport_connect(struct ndn_TcpTransport *self,
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, uint8_t *data, unsigned int dataLength)
static inline ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, uint8_t *data, size_t dataLength)
{
return ndn_SocketTransport_send(&self->base, data, dataLength);
}
@ -72,7 +72,7 @@ static inline ndn_Error ndn_TcpTransport_receiveIsReady(struct ndn_TcpTransport
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_TcpTransport_receive
(struct ndn_TcpTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes)
(struct ndn_TcpTransport *self, uint8_t *buffer, size_t bufferLength, size_t *nBytes)
{
return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes);
}

4
ndn-cpp/c/transport/udp-transport.h

@ -45,7 +45,7 @@ static inline ndn_Error ndn_UdpTransport_connect(struct ndn_UdpTransport *self,
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, uint8_t *data, unsigned int dataLength)
static inline ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, uint8_t *data, size_t dataLength)
{
return ndn_SocketTransport_send(&self->base, data, dataLength);
}
@ -72,7 +72,7 @@ static inline ndn_Error ndn_UdpTransport_receiveIsReady(struct ndn_UdpTransport
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_UdpTransport_receive
(struct ndn_UdpTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes)
(struct ndn_UdpTransport *self, uint8_t *buffer, size_t bufferLength, size_t *nBytes)
{
return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes);
}

4
ndn-cpp/c/util/blob.h

@ -16,7 +16,7 @@ extern "C" {
*/
struct ndn_Blob {
uint8_t *value; /**< pointer to the pre-allocated buffer for the value. Must be treated as read only. */
unsigned int valueLength; /**< the number of bytes in value. */
size_t valueLength; /**< the number of bytes in value. */
};
/**
@ -25,7 +25,7 @@ struct ndn_Blob {
* @param value The pre-allocated buffer for the value, or 0 for none.
* @param valueLength The number of bytes in value.
*/
static inline void ndn_Blob_initialize(struct ndn_Blob *self, uint8_t *value, unsigned int valueLength)
static inline void ndn_Blob_initialize(struct ndn_Blob *self, uint8_t *value, size_t valueLength)
{
self->value = value;
self->valueLength = valueLength;

2
ndn-cpp/c/util/crypto.c

@ -6,7 +6,7 @@
#include "crypto.h"
void ndn_digestSha256(const uint8_t *data, unsigned int dataLength, uint8_t *digest)
void ndn_digestSha256(const uint8_t *data, size_t dataLength, uint8_t *digest)
{
SHA256_CTX sha256;
SHA256_Init(&sha256);

2
ndn-cpp/c/util/crypto.h

@ -21,7 +21,7 @@ extern "C" {
* @param dataLength The length of data.
* @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data.
*/
void ndn_digestSha256(const uint8_t *data, unsigned int dataLength, uint8_t *digest);
void ndn_digestSha256(const uint8_t *data, size_t dataLength, uint8_t *digest);
#ifdef __cplusplus
}

4
ndn-cpp/c/util/dynamic-uint8-array.c

@ -6,13 +6,13 @@
#include "dynamic-uint8-array.h"
ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, unsigned int length)
ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, size_t length)
{
if (!self->realloc)
return NDN_ERROR_DynamicUInt8Array_realloc_function_pointer_not_supplied;
// See if double is enough.
unsigned int newLength = self->length * 2;
size_t newLength = self->length * 2;
if (length > newLength)
// The needed length is much greater, so use it.
newLength = length;

14
ndn-cpp/c/util/dynamic-uint8-array.h

@ -16,9 +16,9 @@ extern "C" {
struct ndn_DynamicUInt8Array {
uint8_t *array; /**< the allocated array buffer */
unsigned int length; /**< the length of the allocated array buffer */
size_t length; /**< the length of the allocated array buffer */
uint8_t * (*realloc)
(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length); /**< a pointer to a function that reallocates array and returns a new pointer to a buffer of
(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length); /**< a pointer to a function that reallocates array and returns a new pointer to a buffer of
* length bytes, or 0 for error. On success, the contents of the old buffer are copied to the new one.
* On success, the original array pointer will no longer be used.
* self is a pointer to the struct ndn_DynamicUInt8Array which is calling realloc.
@ -33,8 +33,8 @@ struct ndn_DynamicUInt8Array {
* @param reallocFunction see ndn_DynamicUInt8Array_ensureLength. This may be 0.
*/
static inline void ndn_DynamicUInt8Array_initialize
(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length,
uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, unsigned int))
(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length,
uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, size_t))
{
self->array = array;
self->length = length;
@ -49,7 +49,7 @@ static inline void ndn_DynamicUInt8Array_initialize
* @param length the needed minimum size for self->length
* @return 0 for success, else an error code if can't reallocate the array
*/
ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, unsigned int length);
ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, size_t length);
/**
* Ensure that self->length is greater than or equal to length. If it is, just return 0 for success.
@ -59,7 +59,7 @@ ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self,
* @param length the needed minimum size for self->length
* @return 0 for success, else an error code if need to reallocate the array but can't
*/
static inline ndn_Error ndn_DynamicUInt8Array_ensureLength(struct ndn_DynamicUInt8Array *self, unsigned int length)
static inline ndn_Error ndn_DynamicUInt8Array_ensureLength(struct ndn_DynamicUInt8Array *self, size_t length)
{
if (self->length >= length)
return NDN_ERROR_success;
@ -76,7 +76,7 @@ static inline ndn_Error ndn_DynamicUInt8Array_ensureLength(struct ndn_DynamicUIn
* @return 0 for success, else an error code if need to reallocate the array but can't
*/
static inline ndn_Error ndn_DynamicUInt8Array_set
(struct ndn_DynamicUInt8Array *self, uint8_t *value, unsigned int valueLength, unsigned int offset)
(struct ndn_DynamicUInt8Array *self, uint8_t *value, size_t valueLength, size_t offset)
{
ndn_Error error;
if ((error = ndn_DynamicUInt8Array_ensureLength(self, valueLength + offset)))

12
ndn-cpp/c/util/ndn_memory.c

@ -7,9 +7,9 @@
#include "ndn_memory.h"
#if !HAVE_MEMCMP
int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len)
int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len)
{
unsigned int i;
size_t i;
for (i = 0; i < len; i++) {
if (buf1[i] > buf2[i])
@ -25,9 +25,9 @@ int ndn_memcmp_stub_to_avoid_empty_file_warning = 0;
#endif
#if !HAVE_MEMCPY
void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len)
void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len)
{
unsigned int i;
size_t i;
for (i = 0; i < len; i++)
dest[i] = src[i];
@ -37,9 +37,9 @@ int ndn_memcpy_stub_to_avoid_empty_file_warning = 0;
#endif
#if !HAVE_MEMSET
void ndn_memset(uint8_t *dest, int val, unsigned int len)
void ndn_memset(uint8_t *dest, int val, size_t len)
{
unsigned int i;
size_t i;
for (i = 0; i < len; i++)
dest[i] = (uint8_t)val;

12
ndn-cpp/c/util/ndn_memory.h

@ -22,12 +22,12 @@ extern "C" {
/**
* Use the library version of memcmp.
*/
static inline int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len) { return memcmp(buf1, buf2, len); }
static inline int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len) { return memcmp(buf1, buf2, len); }
#else
/**
* Use a local implementation of memcmp instead of the library version.
*/
int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len);
int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len);
#endif
#if HAVE_MEMCPY
@ -35,12 +35,12 @@ int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len);
/**
* Use the library version of memcpy.
*/
static inline void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len) { memcpy(dest, src, len); }
static inline void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len) { memcpy(dest, src, len); }
#else
/**
* Use a local implementation of memcpy instead of the library version.
*/
void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len);
void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len);
#endif
#if HAVE_MEMSET
@ -48,12 +48,12 @@ void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len);
/**
* Use the library version of memset.
*/
static inline void ndn_memset(uint8_t *dest, int val, unsigned int len) { memset(dest, val, len); }
static inline void ndn_memset(uint8_t *dest, int val, size_t len) { memset(dest, val, len); }
#else
/**
* Use a local implementation of memset instead of the library version.
*/
void ndn_memset(uint8_t *dest, int val, unsigned int len);
void ndn_memset(uint8_t *dest, int val, size_t len);
#endif
#ifdef __cplusplus

2
ndn-cpp/c/util/ndn_realloc.c

@ -7,7 +7,7 @@
#include <stdlib.h>
#include "ndn_realloc.h"
uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length)
uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length)
{
return (uint8_t *)realloc(array, length);
}

2
ndn-cpp/c/util/ndn_realloc.h

@ -21,7 +21,7 @@ extern "C" {
* @param length the length for the new array buffer.
* @return the new allocated array buffer.
*/
uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length);
uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length);
#ifdef __cplusplus
}

2
ndn-cpp/common.cpp

@ -19,7 +19,7 @@ toHex(const vector<uint8_t>& array)
ostringstream result;
result.flags(ios::hex | ios::uppercase);
for (unsigned int i = 0; i < array.size(); ++i) {
for (size_t i = 0; i < array.size(); ++i) {
uint8_t x = array[i];
if (x < 16)
result << '0';

6
ndn-cpp/data.cpp

@ -72,7 +72,7 @@ Data::set(const struct ndn_Data& dataStruct)
SignedBlob
Data::wireEncode(WireFormat& wireFormat)
{
unsigned int signedPortionBeginOffset, signedPortionEndOffset;
size_t signedPortionBeginOffset, signedPortionEndOffset;
Blob encoding = wireFormat.encodeData(*this, &signedPortionBeginOffset, &signedPortionEndOffset);
wireEncoding_ = SignedBlob(encoding, signedPortionBeginOffset, signedPortionEndOffset);
@ -80,9 +80,9 @@ Data::wireEncode(WireFormat& wireFormat)
}
void
Data::wireDecode(const uint8_t* input, unsigned int inputLength, WireFormat& wireFormat)
Data::wireDecode(const uint8_t* input, size_t inputLength, WireFormat& wireFormat)
{
unsigned int signedPortionBeginOffset, signedPortionEndOffset;
size_t signedPortionBeginOffset, signedPortionEndOffset;
wireFormat.decodeData(*this, input, inputLength, &signedPortionBeginOffset, &signedPortionEndOffset);
wireEncoding_ = SignedBlob(input, inputLength, signedPortionBeginOffset, signedPortionEndOffset);

6
ndn-cpp/data.hpp

@ -101,7 +101,7 @@ public:
setFinalBlockID(const std::vector<uint8_t>& finalBlockID) { finalBlockID_ = Name::Component(finalBlockID); }
void
setFinalBlockID(const uint8_t* finalBlockID, unsigned int finalBlockIdLength)
setFinalBlockID(const uint8_t* finalBlockID, size_t finalBlockIdLength)
{
finalBlockID_ = Name::Component(finalBlockID, finalBlockIdLength);
}
@ -142,7 +142,7 @@ public:
* @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat().
*/
void
wireDecode(const uint8_t* input, unsigned int inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
wireDecode(const uint8_t* input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());
/**
* Decode the input using a particular wire format and update this Data. Also, set the wireEncoding field to the input.
@ -257,7 +257,7 @@ public:
}
void
setContent(const uint8_t* content, unsigned int contentLength)
setContent(const uint8_t* content, size_t contentLength)
{
content_ = Blob(content, contentLength);
onChanged();

2
ndn-cpp/encoding/binary-xml-decoder.hpp

@ -22,7 +22,7 @@ public:
/**
* Initialize the base ndn_BinaryXmlDecoder struct with the input.
*/
BinaryXmlDecoder(const uint8_t *input, unsigned int inputLength)
BinaryXmlDecoder(const uint8_t *input, size_t inputLength)
{
ndn_BinaryXmlDecoder_initialize(this, (uint8_t *)input, inputLength);
}

2
ndn-cpp/encoding/binary-xml-element-reader.cpp

@ -9,7 +9,7 @@
namespace ndn {
void
ElementListener::staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength)
ElementListener::staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength)
{
((ElementListener *)self)->onReceivedElement(element, elementLength);
}

4
ndn-cpp/encoding/binary-xml-element-reader.hpp

@ -29,7 +29,7 @@ public:
* @param elementLength length of element
*/
virtual void
onReceivedElement(const uint8_t *element, unsigned int elementLength) = 0;
onReceivedElement(const uint8_t *element, size_t elementLength) = 0;
private:
/**
@ -39,7 +39,7 @@ private:
* @param elementLength
*/
static void
staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength);
staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength);
};
}

4
ndn-cpp/encoding/binary-xml-structure-decoder.hpp

@ -31,7 +31,7 @@ public:
* @return true if found the element end, false if need to read more. (This is the same as returning gotElementEnd().)
*/
bool
findElementEnd(uint8_t *input, unsigned int inputLength)
findElementEnd(uint8_t *input, size_t inputLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlStructureDecoder_findElementEnd(this, input, inputLength)))
@ -39,7 +39,7 @@ public:
return gotElementEnd();
}
unsigned int
size_t
getOffset() const { return offset; }
bool

8
ndn-cpp/encoding/binary-xml-wire-format.cpp

@ -46,7 +46,7 @@ BinaryXmlWireFormat::encodeInterest(const Interest& interest)
}
void
BinaryXmlWireFormat::decodeInterest(Interest& interest, const uint8_t *input, unsigned int inputLength)
BinaryXmlWireFormat::decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength)
{
struct ndn_NameComponent nameComponents[100];
struct ndn_ExcludeEntry excludeEntries[100];
@ -64,7 +64,7 @@ BinaryXmlWireFormat::decodeInterest(Interest& interest, const uint8_t *input, un
}
Blob
BinaryXmlWireFormat::encodeData(const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset)
BinaryXmlWireFormat::encodeData(const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset)
{
struct ndn_NameComponent nameComponents[100];
struct ndn_NameComponent keyNameComponents[100];
@ -84,7 +84,7 @@ BinaryXmlWireFormat::encodeData(const Data& data, unsigned int *signedPortionBeg
void
BinaryXmlWireFormat::decodeData
(Data& data, const uint8_t *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset)
(Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset)
{
struct ndn_NameComponent nameComponents[100];
struct ndn_NameComponent keyNameComponents[100];
@ -119,7 +119,7 @@ BinaryXmlWireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntr
}
void
BinaryXmlWireFormat::decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, unsigned int inputLength)
BinaryXmlWireFormat::decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength)
{
struct ndn_NameComponent prefixNameComponents[100];
struct ndn_ForwardingEntry forwardingEntryStruct;

12
ndn-cpp/encoding/binary-xml-wire-format.hpp

@ -32,7 +32,7 @@ public:
* @param inputLength The number of bytes in input.
*/
virtual void
decodeInterest(Interest& interest, const uint8_t *input, unsigned int inputLength);
decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength);
/**
* Encode data with binary XML and return the encoding.
@ -45,7 +45,7 @@ public:
*/
virtual Blob
encodeData
(const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
(const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
/**
* Decode input as a data packet in binary XML and set the fields in the data object.
@ -54,14 +54,14 @@ public:
* @param inputLength The number of bytes in input.
* @param signedPortionBeginOffset Return the offset in the input buffer of the beginning of the signed portion.
* If you are not decoding in order to verify, you can call
* decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value.
* decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
* @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion.
* If you are not decoding in order to verify, you can call
* decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value.
* decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
*/
virtual void
decodeData
(Data& data, const uint8_t *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
(Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
/**
* Encode forwardingEntry in binary XML and return the encoding.
@ -78,7 +78,7 @@ public:
* @param inputLength The number of bytes in input.
*/
virtual void
decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, unsigned int inputLength);
decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength);
};
}

8
ndn-cpp/encoding/wire-format.cpp

@ -35,20 +35,20 @@ WireFormat::encodeInterest(const Interest& interest)
}
void
WireFormat::decodeInterest(Interest& interest, const uint8_t *input, unsigned int inputLength)
WireFormat::decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength)
{
throw logic_error("unimplemented");
}
Blob
WireFormat::encodeData(const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset)
WireFormat::encodeData(const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset)
{
throw logic_error("unimplemented");
}
void
WireFormat::decodeData
(Data& data, const uint8_t *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset)
(Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset)
{
throw logic_error("unimplemented");
}
@ -60,7 +60,7 @@ WireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntry)
}
void
WireFormat::decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, unsigned int inputLength)
WireFormat::decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength)
{
throw logic_error("unimplemented");
}

18
ndn-cpp/encoding/wire-format.hpp

@ -35,7 +35,7 @@ public:
* @throw logic_error for unimplemented if the derived class does not override.
*/
virtual void
decodeInterest(Interest& interest, const uint8_t *input, unsigned int inputLength);
decodeInterest(Interest& interest, const uint8_t *input, size_t inputLength);
/**
* Encode data and return the encoding. Your derived class should override.
@ -49,7 +49,7 @@ public:
*/
virtual Blob
encodeData
(const Data& data, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
(const Data& data, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
/**
* Encode data and return the encoding.
@ -60,7 +60,7 @@ public:
Blob
encodeData(const Data& data)
{
unsigned int dummyBeginOffset, dummyEndOffset;
size_t dummyBeginOffset, dummyEndOffset;
return encodeData(data, &dummyBeginOffset, &dummyEndOffset);
}
@ -71,20 +71,20 @@ public:
* @param inputLength The number of bytes in input.
* @param signedPortionBeginOffset Return the offset in the input buffer of the beginning of the signed portion.
* If you are not decoding in order to verify, you can call
* decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value.
* decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
* @param signedPortionEndOffset Return the offset in the input buffer of the end of the signed portion.
* If you are not decoding in order to verify, you can call
* decodeData(Data& data, const uint8_t *input, unsigned int inputLength) to ignore this returned value.
* decodeData(Data& data, const uint8_t *input, size_t inputLength) to ignore this returned value.
* @throw logic_error for unimplemented if the derived class does not override.
*/
virtual void
decodeData
(Data& data, const uint8_t *input, unsigned int inputLength, unsigned int *signedPortionBeginOffset, unsigned int *signedPortionEndOffset);
(Data& data, const uint8_t *input, size_t inputLength, size_t *signedPortionBeginOffset, size_t *signedPortionEndOffset);
void
decodeData(Data& data, const uint8_t *input, unsigned int inputLength)
decodeData(Data& data, const uint8_t *input, size_t inputLength)
{
unsigned int dummyBeginOffset, dummyEndOffset;
size_t dummyBeginOffset, dummyEndOffset;
decodeData(data, input, inputLength, &dummyBeginOffset, &dummyEndOffset);
}
@ -105,7 +105,7 @@ public:
* @throw logic_error for unimplemented if the derived class does not override.
*/
virtual void
decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, unsigned int inputLength);
decodeForwardingEntry(ForwardingEntry& forwardingEntry, const uint8_t *input, size_t inputLength);
/**
* Set the static default WireFormat used by default encoding and decoding methods.

2
ndn-cpp/forwarding-entry.hpp

@ -39,7 +39,7 @@ public:
}
void
wireDecode(const uint8_t *input, unsigned int inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
wireDecode(const uint8_t *input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
{
wireFormat.decodeForwardingEntry(*this, input, inputLength);
}

4
ndn-cpp/interest.cpp

@ -19,7 +19,7 @@ Exclude::get(struct ndn_Exclude& excludeStruct) const
throw runtime_error("excludeStruct.maxEntries must be >= this exclude getEntryCount()");
excludeStruct.nEntries = entries_.size();
for (unsigned int i = 0; i < excludeStruct.nEntries; ++i)
for (size_t i = 0; i < excludeStruct.nEntries; ++i)
entries_[i].get(excludeStruct.entries[i]);
}
@ -27,7 +27,7 @@ void
Exclude::set(const struct ndn_Exclude& excludeStruct)
{
entries_.clear();
for (unsigned int i = 0; i < excludeStruct.nEntries; ++i) {
for (size_t i = 0; i < excludeStruct.nEntries; ++i) {
ndn_ExcludeEntry *entry = &excludeStruct.entries[i];
if (entry->type == ndn_Exclude_COMPONENT)

10
ndn-cpp/interest.hpp

@ -29,7 +29,7 @@ public:
/**
* Create an ExcludeEntry of type ndn_Exclude_COMPONENT
*/
ExcludeEntry(uint8_t *component, unsigned int componentLen)
ExcludeEntry(uint8_t *component, size_t componentLen)
: type_(ndn_Exclude_COMPONENT), component_(component, componentLen)
{
}
@ -67,13 +67,13 @@ public:
Exclude() {
}
unsigned int
size_t
getEntryCount() const {
return entries_.size();
}
const ExcludeEntry&
getEntry(unsigned int i) const { return entries_[i]; }
getEntry(size_t i) const { return entries_[i]; }
/**
* Set the excludeStruct to point to the entries in this Exclude, without copying any memory.
@ -103,7 +103,7 @@ public:
* Add a new entry of type ndn_Exclude_COMPONENT, copying from component of length compnentLength
*/
void
addComponent(uint8_t *component, unsigned int componentLen)
addComponent(uint8_t *component, size_t componentLen)
{
entries_.push_back(ExcludeEntry(component, componentLen));
}
@ -175,7 +175,7 @@ public:
}
void
wireDecode(const uint8_t *input, unsigned int inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
wireDecode(const uint8_t *input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
{
wireFormat.decodeInterest(*this, input, inputLength);
}

2
ndn-cpp/key.hpp

@ -68,7 +68,7 @@ public:
setKeyData(const std::vector<uint8_t>& keyData) { keyData_ = keyData; }
void
setKeyData(const uint8_t *keyData, unsigned int keyDataLength)
setKeyData(const uint8_t *keyData, size_t keyDataLength)
{
keyData_ = Blob(keyData, keyDataLength);
}

22
ndn-cpp/name.cpp

@ -87,7 +87,7 @@ unescape(const string& str)
{
ostringstream result;
for (unsigned int i = 0; i < str.size(); ++i) {
for (size_t i = 0; i < str.size(); ++i) {
if (str[i] == '%' && i + 2 < str.size()) {
int hi = fromHexChar(str[i + 1]);
int lo = fromHexChar(str[i + 2]);
@ -110,7 +110,7 @@ unescape(const string& str)
}
Blob
Name::Component::makeFromEscapedString(const char *escapedString, unsigned int beginOffset, unsigned int endOffset)
Name::Component::makeFromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset)
{
string trimmedString(escapedString + beginOffset, escapedString + endOffset);
trim(trimmedString);
@ -212,7 +212,7 @@ Name::get(struct ndn_Name& nameStruct) const
throw runtime_error("nameStruct.maxComponents must be >= this name getNComponents()");
nameStruct.nComponents = components_.size();
for (unsigned int i = 0; i < nameStruct.nComponents; ++i)
for (size_t i = 0; i < nameStruct.nComponents; ++i)
components_[i].get(nameStruct.components[i]);
}
@ -220,7 +220,7 @@ void
Name::set(const struct ndn_Name& nameStruct)
{
clear();
for (unsigned int i = 0; i < nameStruct.nComponents; ++i)
for (size_t i = 0; i < nameStruct.nComponents; ++i)
addComponent(nameStruct.components[i].value, nameStruct.components[i].valueLength);
}
@ -244,7 +244,7 @@ Name::toUri() const
return "/";
ostringstream result;
for (unsigned int i = 0; i < components_.size(); ++i) {
for (size_t i = 0; i < components_.size(); ++i) {
result << "/";
toEscapedString(*components_[i].getValue(), result);
}
@ -257,8 +257,8 @@ Name::getSubName(size_t iStartComponent, size_t nComponents) const
{
Name result;
unsigned int iEnd = iStartComponent + nComponents;
for (unsigned int i = iStartComponent; i < iEnd && i < components_.size(); ++i)
size_t iEnd = iStartComponent + nComponents;
for (size_t i = iStartComponent; i < iEnd && i < components_.size(); ++i)
result.components_.push_back(components_[i]);
return result;
@ -269,7 +269,7 @@ Name::getSubName(size_t iStartComponent) const
{
Name result;
for (unsigned int i = iStartComponent; i < components_.size(); ++i)
for (size_t i = iStartComponent; i < components_.size(); ++i)
result.components_.push_back(components_[i]);
return result;
@ -285,7 +285,7 @@ Name::match(const Name& name) const
return 0;
// Check if at least one of given components doesn't match.
unsigned int i;
size_t i;
for (i = 0; i < components_.size(); ++i) {
const Component &selfComponent = components_[i];
const Component &nameComponent = name.components_[i];
@ -310,14 +310,14 @@ Name::toEscapedString(const vector<uint8_t>& value, ostringstream& result)
if (!gotNonDot) {
// Special case for component of zero or more periods. Add 3 periods.
result << "...";
for (unsigned int i = 0; i < value.size(); ++i)
for (size_t i = 0; i < value.size(); ++i)
result << '.';
}
else {
// In case we need to escape, set to upper case hex and save the previous flags.
ios::fmtflags saveFlags = result.flags(ios::hex | ios::uppercase);
for (unsigned int i = 0; i < value.size(); ++i) {
for (size_t i = 0; i < value.size(); ++i) {
uint8_t x = value[i];
// Check for 0-9, A-Z, a-z, (+), (-), (.), (_)
if (x >= 0x30 && x <= 0x39 || x >= 0x41 && x <= 0x5a ||

14
ndn-cpp/name.hpp

@ -44,7 +44,7 @@ public:
* @param value Pointer to the value byte array.
* @param valueLen Length of value.
*/
Component(const uint8_t *value, unsigned int valueLen)
Component(const uint8_t *value, size_t valueLen)
: value_(value, valueLen)
{
}
@ -109,7 +109,7 @@ public:
* @return The component value as a Blob, or a Blob with a null pointer if escapedString is not a valid escaped component.
*/
static Blob
makeFromEscapedString(const char *escapedString, unsigned int beginOffset, unsigned int endOffset);
makeFromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
/**
* Make a component as the encoded segment number.
@ -174,7 +174,7 @@ public:
* @return This name so that you can chain calls to append.
*/
Name&
append(const uint8_t *value, unsigned int valueLength)
append(const uint8_t *value, size_t valueLength)
{
components_.push_back(Component(value, valueLength));
return *this;
@ -210,7 +210,7 @@ public:
* @deprecated Use append.
*/
Name&
appendComponent(const uint8_t *value, unsigned int valueLength)
appendComponent(const uint8_t *value, size_t valueLength)
{
return append(value, valueLength);
}
@ -237,7 +237,7 @@ public:
* @deprecated Use append.
*/
Name&
addComponent(const uint8_t *value, unsigned int valueLength)
addComponent(const uint8_t *value, size_t valueLength)
{
return append(value, valueLength);
}
@ -272,13 +272,13 @@ public:
* Get the number of components.
* @return The number of components.
*/
unsigned int
size_t
getComponentCount() const {
return components_.size();
}
const Component&
getComponent(unsigned int i) const { return components_[i]; }
getComponent(size_t i) const { return components_[i]; }
/**
* Get a new name, constructed as a subset of components.

8
ndn-cpp/node.cpp

@ -102,7 +102,7 @@ selfregSign(Data& data, WireFormat& wireFormat)
if (!success)
throw std::runtime_error("Error in RSA_sign");
signature->setSignature(signatureBits, signatureBitsLength);
signature->setSignature(signatureBits, (size_t)signatureBitsLength);
}
// Use gettimeofday to return the current time in milliseconds.
@ -224,7 +224,7 @@ Node::processEvents()
}
void
Node::onReceivedElement(const uint8_t *element, unsigned int elementLength)
Node::onReceivedElement(const uint8_t *element, size_t elementLength)
{
BinaryXmlDecoder decoder(element, elementLength);
@ -269,7 +269,7 @@ Node::getEntryIndexForExpressedInterest(const Name& name)
int iResult = -1;
for (unsigned int i = 0; i < pit_.size(); ++i) {
for (size_t i = 0; i < pit_.size(); ++i) {
if (ndn_Interest_matchesName((struct ndn_Interest *)&pit_[i]->getInterestStruct(), &nameStruct)) {
if (iResult < 0 ||
pit_[i]->getInterestStruct().name.nComponents > pit_[iResult]->getInterestStruct().name.nComponents)
@ -286,7 +286,7 @@ Node::getEntryForRegisteredPrefix(const Name& name)
{
int iResult = -1;
for (unsigned int i = 0; i < registeredPrefixTable_.size(); ++i) {
for (size_t i = 0; i < registeredPrefixTable_.size(); ++i) {
if (registeredPrefixTable_[i]->getPrefix()->match(name)) {
if (iResult < 0 ||
registeredPrefixTable_[i]->getPrefix()->getComponentCount() > registeredPrefixTable_[iResult]->getPrefix()->getComponentCount())

2
ndn-cpp/node.hpp

@ -90,7 +90,7 @@ public:
getConnectionInfo() { return connectionInfo_; }
void
onReceivedElement(const uint8_t *element, unsigned int elementLength);
onReceivedElement(const uint8_t *element, size_t elementLength);
void
shutdown();

2
ndn-cpp/publisher-public-key-digest.hpp

@ -58,7 +58,7 @@ public:
}
void
setPublisherPublicKeyDigest(const uint8_t *publisherPublicKeyDigest, unsigned int publisherPublicKeyDigestLength)
setPublisherPublicKeyDigest(const uint8_t *publisherPublicKeyDigest, size_t publisherPublicKeyDigestLength)
{
publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
}

8
ndn-cpp/security/identity/memory-private-key-storage.cpp

@ -44,7 +44,7 @@ MemoryPrivateKeyStorage::getPublicKey(const Name& keyName)
}
Blob
MemoryPrivateKeyStorage::sign(const uint8_t *data, unsigned int dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm)
MemoryPrivateKeyStorage::sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm)
{
if (digestAlgorithm != DIGEST_ALGORITHM_SHA256)
return Blob();
@ -62,11 +62,11 @@ MemoryPrivateKeyStorage::sign(const uint8_t *data, unsigned int dataLength, cons
if (!RSA_sign(NID_sha256, digest, sizeof(digest), signatureBits, &signatureBitsLength, privateKey->second->getPrivateKey()))
throw SecurityException("Error in RSA_sign");
return Blob(signatureBits, signatureBitsLength);
return Blob(signatureBits, (size_t)signatureBitsLength);
}
Blob
MemoryPrivateKeyStorage::decrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric)
MemoryPrivateKeyStorage::decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
{
#if 1
throw std::runtime_error("MemoryPrivateKeyStorage::decrypt not implemented");
@ -74,7 +74,7 @@ MemoryPrivateKeyStorage::decrypt(const Name& keyName, const uint8_t* data, unsig
}
Blob
MemoryPrivateKeyStorage::encrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric)
MemoryPrivateKeyStorage::encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
{
#if 1
throw std::runtime_error("MemoryPrivateKeyStorage::encrypt not implemented");

6
ndn-cpp/security/identity/memory-private-key-storage.hpp

@ -65,7 +65,7 @@ public:
* @return The signature, or a null pointer if signing fails.
*/
virtual Blob
sign(const uint8_t *data, unsigned int dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
/**
* Decrypt data.
@ -76,7 +76,7 @@ public:
* @return The decrypted data.
*/
virtual Blob
decrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric);
decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
/**
* Encrypt data.
@ -87,7 +87,7 @@ public:
* @return The encrypted data.
*/
virtual Blob
encrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric);
encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
/**
* @brief Generate a symmetric key.

6
ndn-cpp/security/identity/private-key-storage.hpp

@ -50,7 +50,7 @@ public:
* @return The signature, or a null pointer if signing fails.
*/
virtual Blob
sign(const uint8_t *data, unsigned int dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256) = 0;
sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256) = 0;
Blob
sign(const Blob& data, const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256)
@ -67,7 +67,7 @@ public:
* @return The decrypted data.
*/
virtual Blob
decrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric = false) = 0;
decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false) = 0;
Blob
decrypt(const Name& keyName, const Blob& data, bool isSymmetric = false)
@ -84,7 +84,7 @@ public:
* @return The encrypted data.
*/
virtual Blob
encrypt(const Name& keyName, const uint8_t* data, unsigned int dataLength, bool isSymmetric = false) = 0;
encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false) = 0;
Blob
encrypt(const Name& keyName, const Blob& data, bool isSymmetric = false)

6
ndn-cpp/sha256-with-rsa-signature.hpp

@ -65,7 +65,7 @@ public:
setDigestAlgorithm(const std::vector<uint8_t>& digestAlgorithm) { digestAlgorithm_ = digestAlgorithm; }
void
setDigestAlgorithm(const uint8_t *digestAlgorithm, unsigned int digestAlgorithmLength)
setDigestAlgorithm(const uint8_t *digestAlgorithm, size_t digestAlgorithmLength)
{
digestAlgorithm_ = Blob(digestAlgorithm, digestAlgorithmLength);
}
@ -74,7 +74,7 @@ public:
setWitness(const std::vector<uint8_t>& witness) { witness_ = witness; }
void
setWitness(const uint8_t *witness, unsigned int witnessLength)
setWitness(const uint8_t *witness, size_t witnessLength)
{
witness_ = Blob(witness, witnessLength);
}
@ -83,7 +83,7 @@ public:
setSignature(const std::vector<uint8_t>& signature) { signature_ = signature; }
void
setSignature(const uint8_t *signature, unsigned int signatureLength)
setSignature(const uint8_t *signature, size_t signatureLength)
{
signature_ = Blob(signature, signatureLength);
}

6
ndn-cpp/transport/tcp-transport.cpp

@ -27,7 +27,7 @@ TcpTransport::connect(const Transport::ConnectionInfo& connectionInfo, ElementLi
throw std::runtime_error(ndn_getErrorString(error));
// TODO: This belongs in the socket listener.
const unsigned int initialLength = 1000;
const size_t initialLength = 1000;
// Automatically cast elementReader_ to (struct ndn_ElementListener *)
ndn_BinaryXmlElementReader_initialize
(&elementReader_, &elementListener, (uint8_t *)malloc(initialLength), initialLength, ndn_realloc);
@ -37,7 +37,7 @@ TcpTransport::connect(const Transport::ConnectionInfo& connectionInfo, ElementLi
}
void
TcpTransport::send(const uint8_t *data, unsigned int dataLength)
TcpTransport::send(const uint8_t *data, size_t dataLength)
{
ndn_Error error;
if ((error = ndn_TcpTransport_send(&transport_, (uint8_t *)data, dataLength)))
@ -55,7 +55,7 @@ TcpTransport::processEvents()
return;
uint8_t buffer[8000];
unsigned int nBytes;
size_t nBytes;
if ((error = ndn_TcpTransport_receive(&transport_, buffer, sizeof(buffer), &nBytes)))
throw std::runtime_error(ndn_getErrorString(error));

2
ndn-cpp/transport/tcp-transport.hpp

@ -72,7 +72,7 @@ public:
* @param data A pointer to the buffer of data to send.
* @param dataLength The number of bytes in data.
*/
virtual void send(const uint8_t *data, unsigned int dataLength);
virtual void send(const uint8_t *data, size_t dataLength);
/**
* Process any data to receive. For each element received, call elementListener.onReceivedElement.

2
ndn-cpp/transport/transport.cpp

@ -22,7 +22,7 @@ Transport::connect(const Transport::ConnectionInfo& connectionInfo, ElementListe
}
void
Transport::send(const uint8_t *data, unsigned int dataLength)
Transport::send(const uint8_t *data, size_t dataLength)
{
throw logic_error("unimplemented");
}

2
ndn-cpp/transport/transport.hpp

@ -37,7 +37,7 @@ public:
* @param dataLength The number of bytes in data.
*/
virtual void
send(const uint8_t *data, unsigned int dataLength);
send(const uint8_t *data, size_t dataLength);
void
send(const std::vector<uint8_t>& data)

6
ndn-cpp/transport/udp-transport.cpp

@ -27,7 +27,7 @@ UdpTransport::connect(const Transport::ConnectionInfo& connectionInfo, ElementLi
throw std::runtime_error(ndn_getErrorString(error));
// TODO: This belongs in the socket listener.
const unsigned int initialLength = 1000;
const size_t initialLength = 1000;
// Automatically cast elementReader_ to (struct ndn_ElementListener *)
ndn_BinaryXmlElementReader_initialize
(&elementReader_, &elementListener, (uint8_t *)malloc(initialLength), initialLength, ndn_realloc);
@ -37,7 +37,7 @@ UdpTransport::connect(const Transport::ConnectionInfo& connectionInfo, ElementLi
}
void
UdpTransport::send(const uint8_t *data, unsigned int dataLength)
UdpTransport::send(const uint8_t *data, size_t dataLength)
{
ndn_Error error;
if ((error = ndn_UdpTransport_send(&transport_, (uint8_t *)data, dataLength)))
@ -55,7 +55,7 @@ UdpTransport::processEvents()
return;
uint8_t buffer[8000];
unsigned int nBytes;
size_t nBytes;
if ((error = ndn_UdpTransport_receive(&transport_, buffer, sizeof(buffer), &nBytes)))
throw std::runtime_error(ndn_getErrorString(error));

2
ndn-cpp/transport/udp-transport.hpp

@ -74,7 +74,7 @@ public:
* @param dataLength The number of bytes in data.
*/
virtual void
send(const uint8_t *data, unsigned int dataLength);
send(const uint8_t *data, size_t dataLength);
/**
* Process any data to receive. For each element received, call elementListener.onReceivedElement.

4
ndn-cpp/util/blob.hpp

@ -35,7 +35,7 @@ public:
* @param value A pointer to the byte array which is copied.
* @param valueLength The length of value.
*/
Blob(const uint8_t* value, unsigned int valueLength)
Blob(const uint8_t* value, size_t valueLength)
: ptr_lib::shared_ptr<const std::vector<uint8_t> >(new std::vector<uint8_t>(value, value + valueLength))
{
}
@ -68,7 +68,7 @@ public:
/**
* Return the length of the immutable byte array.
*/
unsigned int
size_t
size() const
{
if (*this)

2
ndn-cpp/util/changed-event.cpp

@ -13,7 +13,7 @@ namespace ndn {
void
ChangedEvent::fire()
{
for (unsigned int i = 0; i < listeners_.size(); ++i)
for (size_t i = 0; i < listeners_.size(); ++i)
listeners_[i]();
}

4
ndn-cpp/util/dynamic-uint8-vector.cpp

@ -10,14 +10,14 @@ using namespace std;
namespace ndn {
DynamicUInt8Vector::DynamicUInt8Vector(unsigned int initialLength)
DynamicUInt8Vector::DynamicUInt8Vector(size_t initialLength)
: vector_(new vector<uint8_t>(initialLength))
{
ndn_DynamicUInt8Array_initialize(this, &vector_->front(), initialLength, DynamicUInt8Vector::realloc);
}
uint8_t*
DynamicUInt8Vector::realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length)
DynamicUInt8Vector::realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length)
{
// Because this method is private, assume there is not a problem with upcasting.
DynamicUInt8Vector *thisObject = (DynamicUInt8Vector *)self;

4
ndn-cpp/util/dynamic-uint8-vector.hpp

@ -23,7 +23,7 @@ public:
* Create a new DynamicUInt8Vector with an initial length.
* @param initialLength The initial size of the allocated vector.
*/
DynamicUInt8Vector(unsigned int initialLength);
DynamicUInt8Vector(size_t initialLength);
/**
* Get the shared_ptr to the allocated vector.
@ -41,7 +41,7 @@ private:
* @return The front of the allocated vector.
*/
static uint8_t*
realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length);
realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length);
ptr_lib::shared_ptr<std::vector<uint8_t> > vector_;
};

18
ndn-cpp/util/signed-blob.hpp

@ -34,7 +34,7 @@ public:
* @param signedPortionEndOffset The offset in the encoding of the end of the signed portion.
*/
SignedBlob
(const uint8_t* value, unsigned int valueLength, unsigned int signedPortionBeginOffset, unsigned int signedPortionEndOffset)
(const uint8_t* value, size_t valueLength, size_t signedPortionBeginOffset, size_t signedPortionEndOffset)
: Blob(value, valueLength), signedPortionBeginOffset_(signedPortionBeginOffset), signedPortionEndOffset_(signedPortionEndOffset)
{
}
@ -48,7 +48,7 @@ public:
* @param signedPortionEndOffset The offset in the encoding of the end of the signed portion.
*/
SignedBlob
(const std::vector<uint8_t> &value, unsigned int signedPortionBeginOffset, unsigned int signedPortionEndOffset)
(const std::vector<uint8_t> &value, size_t signedPortionBeginOffset, size_t signedPortionEndOffset)
: Blob(value), signedPortionBeginOffset_(signedPortionBeginOffset), signedPortionEndOffset_(signedPortionEndOffset)
{
}
@ -62,13 +62,13 @@ public:
*/
SignedBlob
(const ptr_lib::shared_ptr<std::vector<uint8_t> > &value,
unsigned int signedPortionBeginOffset, unsigned int signedPortionEndOffset)
size_t signedPortionBeginOffset, size_t signedPortionEndOffset)
: Blob(value), signedPortionBeginOffset_(signedPortionBeginOffset), signedPortionEndOffset_(signedPortionEndOffset)
{
}
SignedBlob
(const ptr_lib::shared_ptr<const std::vector<uint8_t> > &value,
unsigned int signedPortionBeginOffset, unsigned int signedPortionEndOffset)
size_t signedPortionBeginOffset, size_t signedPortionEndOffset)
: Blob(value), signedPortionBeginOffset_(signedPortionBeginOffset), signedPortionEndOffset_(signedPortionEndOffset)
{
}
@ -76,7 +76,7 @@ public:
/**
* Return the length of the signed portion of the immutable byte array, or 0 of the pointer to the array is null.
*/
unsigned int
size_t
signedSize() const
{
if (*this)
@ -101,18 +101,18 @@ public:
/**
* Return the offset in the array of the beginning of the signed portion.
*/
unsigned int
size_t
getSignedPortionBeginOffset() { return signedPortionBeginOffset_; }
/**
* Return the offset in the array of the end of the signed portion.
*/
unsigned int
size_t
getSignedPortionEndOffset() { return signedPortionEndOffset_; }
private:
unsigned int signedPortionBeginOffset_;
unsigned int signedPortionEndOffset_;
size_t signedPortionBeginOffset_;
size_t signedPortionEndOffset_;
};
}

2
tests/test-encode-decode-data.cpp

@ -121,7 +121,7 @@ static void dumpData(const Data& data)
cout << "name: " << data.getName().to_uri() << endl;
if (data.getContent().size() > 0) {
cout << "content (raw): ";
for (unsigned int i = 0; i < data.getContent().size(); ++i)
for (size_t i = 0; i < data.getContent().size(); ++i)
cout << (*data.getContent())[i];
cout<< endl;
cout << "content (hex): " << toHex(*data.getContent()) << endl;

2
tests/test-get-async.cpp

@ -29,7 +29,7 @@ public:
{
++callbackCount_;
cout << "Got data packet with name " << data->getName().to_uri() << endl;
for (unsigned int i = 0; i < data->getContent().size(); ++i)
for (size_t i = 0; i < data->getContent().size(); ++i)
cout << (*data->getContent())[i];
cout << endl;
}

Loading…
Cancel
Save