From d2dfc78e4f98c3567762758df48f3c2518dcd44e Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Thu, 23 Nov 2023 22:11:36 +0000 Subject: [PATCH] Change unsigned to size_t to avoid warnings of size convertion --- src/utarray.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utarray.h b/src/utarray.h index 1fe8bc1..632169e 100644 --- a/src/utarray.h +++ b/src/utarray.h @@ -53,7 +53,7 @@ typedef struct { } UT_icd; typedef struct { - unsigned i,n;/* i: index of next available slot, n: num slots */ + size_t i,n;/* i: index of next available slot, n: num slots */ UT_icd icd; /* initializer, copy and destructor functions */ char *d; /* n slots of size icd->sz*/ } UT_array; @@ -66,7 +66,7 @@ typedef struct { #define utarray_done(a) do { \ if ((a)->n) { \ if ((a)->icd.dtor) { \ - unsigned _ut_i; \ + size_t _ut_i; \ for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ (a)->icd.dtor(utarray_eltptr(a,_ut_i)); \ } \ @@ -146,7 +146,7 @@ typedef struct { ((a)->i - (j))*((a)->icd.sz)); \ } \ if ((a)->icd.copy) { \ - unsigned _ut_i; \ + size_t _ut_i; \ for(_ut_i=0;_ut_i<(w)->i;_ut_i++) { \ (a)->icd.copy(_utarray_eltptr(a, (j) + _ut_i), _utarray_eltptr(w, _ut_i)); \ } \ @@ -158,17 +158,17 @@ typedef struct { } while(0) #define utarray_resize(dst,num) do { \ - unsigned _ut_i; \ - if ((dst)->i > (unsigned)(num)) { \ + size_t _ut_i; \ + if ((dst)->i > (size_t)(num)) { \ if ((dst)->icd.dtor) { \ for (_ut_i = (num); _ut_i < (dst)->i; ++_ut_i) { \ (dst)->icd.dtor(_utarray_eltptr(dst, _ut_i)); \ } \ } \ - } else if ((dst)->i < (unsigned)(num)) { \ + } else if ((dst)->i < (size_t)(num)) { \ utarray_reserve(dst, (num) - (dst)->i); \ if ((dst)->icd.init) { \ - for (_ut_i = (dst)->i; _ut_i < (unsigned)(num); ++_ut_i) { \ + for (_ut_i = (dst)->i; _ut_i < (size_t)(num); ++_ut_i) { \ (dst)->icd.init(_utarray_eltptr(dst, _ut_i)); \ } \ } else { \ @@ -184,7 +184,7 @@ typedef struct { #define utarray_erase(a,pos,len) do { \ if ((a)->icd.dtor) { \ - unsigned _ut_i; \ + size_t _ut_i; \ for (_ut_i = 0; _ut_i < (len); _ut_i++) { \ (a)->icd.dtor(utarray_eltptr(a, (pos) + _ut_i)); \ } \ @@ -204,7 +204,7 @@ typedef struct { #define utarray_clear(a) do { \ if ((a)->i > 0) { \ if ((a)->icd.dtor) { \ - unsigned _ut_i; \ + size_t _ut_i; \ for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ (a)->icd.dtor(_utarray_eltptr(a, _ut_i)); \ } \