globa: Change unsigned int to size_t where it is the size of a byte array or an index/offset into it.
diff --git a/ndn-cpp/c/util/blob.h b/ndn-cpp/c/util/blob.h
index 4784065..1029185 100644
--- a/ndn-cpp/c/util/blob.h
+++ b/ndn-cpp/c/util/blob.h
@@ -16,7 +16,7 @@
*/
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 @@
* @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;
diff --git a/ndn-cpp/c/util/crypto.c b/ndn-cpp/c/util/crypto.c
index 2cdc91b..ec13f68 100644
--- a/ndn-cpp/c/util/crypto.c
+++ b/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);
diff --git a/ndn-cpp/c/util/crypto.h b/ndn-cpp/c/util/crypto.h
index eb7cec5..5bec549 100644
--- a/ndn-cpp/c/util/crypto.h
+++ b/ndn-cpp/c/util/crypto.h
@@ -21,7 +21,7 @@
* @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
}
diff --git a/ndn-cpp/c/util/dynamic-uint8-array.c b/ndn-cpp/c/util/dynamic-uint8-array.c
index 5a7e96d..23bfd7c 100644
--- a/ndn-cpp/c/util/dynamic-uint8-array.c
+++ b/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;
diff --git a/ndn-cpp/c/util/dynamic-uint8-array.h b/ndn-cpp/c/util/dynamic-uint8-array.h
index 8b7b489..6548662 100644
--- a/ndn-cpp/c/util/dynamic-uint8-array.h
+++ b/ndn-cpp/c/util/dynamic-uint8-array.h
@@ -16,9 +16,9 @@
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 @@
* @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 @@
* @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 @@
* @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 @@
* @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)))
diff --git a/ndn-cpp/c/util/ndn_memory.c b/ndn-cpp/c/util/ndn_memory.c
index db92bde..ba3fc2e 100644
--- a/ndn-cpp/c/util/ndn_memory.c
+++ b/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 @@
#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 @@
#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;
diff --git a/ndn-cpp/c/util/ndn_memory.h b/ndn-cpp/c/util/ndn_memory.h
index ba0a85b..68721e8 100644
--- a/ndn-cpp/c/util/ndn_memory.h
+++ b/ndn-cpp/c/util/ndn_memory.h
@@ -22,12 +22,12 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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
diff --git a/ndn-cpp/c/util/ndn_realloc.c b/ndn-cpp/c/util/ndn_realloc.c
index 8e560b9..f3147f4 100644
--- a/ndn-cpp/c/util/ndn_realloc.c
+++ b/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);
}
diff --git a/ndn-cpp/c/util/ndn_realloc.h b/ndn-cpp/c/util/ndn_realloc.h
index 5259f70..7aeb6af 100644
--- a/ndn-cpp/c/util/ndn_realloc.h
+++ b/ndn-cpp/c/util/ndn_realloc.h
@@ -21,7 +21,7 @@
* @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
}