Sun, 22 Dec 2024 22:10:04 +0100
don't trust that size_t always has word width
it should be the case on all platforms supported by UCX, but it's not strictly defined in POSIX that it must be the case
src/array_list.c | file | annotate | diff | comparison | revisions |
--- a/src/array_list.c Sun Dec 22 21:57:53 2024 +0100 +++ b/src/array_list.c Sun Dec 22 22:10:04 2024 +0100 @@ -132,7 +132,7 @@ size_t oldcap; size_t oldsize; size_t max_size; - if (width == 0 || width == CX_WORDSIZE) { + if (width == 0 || width == 8*sizeof(size_t)) { oldcap = *(size_t*) capacity; oldsize = *(size_t*) size; max_size = SIZE_MAX; @@ -186,7 +186,7 @@ *array = newmem; // store new capacity - if (width == 0 || width == CX_WORDSIZE) { + if (width == 0 || width == 8*sizeof(size_t)) { *(size_t*) capacity = newcap; } else if (width == 16) { *(uint16_t*) capacity = (uint16_t) newcap; @@ -225,7 +225,7 @@ size_t oldcap; size_t oldsize; size_t max_size; - if (width == 0 || width == CX_WORDSIZE) { + if (width == 0 || width == 8*sizeof(size_t)) { oldcap = *(size_t*) capacity; oldsize = *(size_t*) size; max_size = SIZE_MAX; @@ -303,7 +303,7 @@ // if any of size or capacity changed, store them back if (newsize != oldsize || newcap != oldcap) { - if (width == 0 || width == CX_WORDSIZE) { + if (width == 0 || width == 8*sizeof(size_t)) { *(size_t*) capacity = newcap; *(size_t*) size = newsize; } else if (width == 16) {