libmapper: use size_t
Use the correct type (size_t) for array sizes.
Change-Id: I337019ab7a4b125f6b64cff29dcf4bff15a80168
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/libmapper/internal.h b/libmapper/internal.h
index e6f9a07..836a5ec 100644
--- a/libmapper/internal.h
+++ b/libmapper/internal.h
@@ -1,8 +1,9 @@
#pragma once
+#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
-int sarraylen(char* array[]);
+size_t sarraylen(char* array[]);
void sarrayfree(char* array[]);
char** sarraydup(char* array[]);
#ifdef __cplusplus
diff --git a/libmapper/mapper.c b/libmapper/mapper.c
index 1d00a32..8acc741 100644
--- a/libmapper/mapper.c
+++ b/libmapper/mapper.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -61,7 +62,7 @@
sd_bus_slot* introspection_slot;
sd_bus_slot* intf_slot;
int* status;
- int count;
+ size_t count;
int finished;
int r;
};
@@ -102,9 +103,9 @@
static int async_subtree_getpaths_callback(sd_bus_message*, void*,
sd_bus_error*);
-int sarraylen(char* array[])
+size_t sarraylen(char* array[])
{
- int count = 0;
+ size_t count = 0;
char** p = array;
while (*p != NULL)
@@ -129,8 +130,8 @@
char** sarraydup(char* array[])
{
- int count = sarraylen(array);
- int i;
+ size_t count = sarraylen(array);
+ size_t i;
char** ret = NULL;
ret = calloc(count + 1, sizeof(*ret));
@@ -175,7 +176,8 @@
static int async_wait_getobject_callback(sd_bus_message* m, void* userdata,
_unused_ sd_bus_error* e)
{
- int i, r;
+ size_t i;
+ int r;
struct async_wait_callback_data* data = userdata;
mapper_async_wait* wait = data->wait;
uint64_t next_retry;
@@ -235,7 +237,8 @@
static int async_wait_get_objects(mapper_async_wait* wait)
{
- int i, r;
+ size_t i;
+ int r;
struct async_wait_callback_data* data = NULL;
for (i = 0; i < wait->count; ++i)
@@ -294,7 +297,7 @@
static int async_wait_check_done(mapper_async_wait* w)
{
- int i;
+ size_t i;
if (w->finished)
return 1;