mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-22 09:13:06 +00:00
libdrgn: vector: fix vector_max_size
(vector_size_type)-1 / sizeof(vector_entry_type) is not a limit;
(vector_size_type)-1 is.
Fixes: b450a7b02b
("libdrgn: vector: support using a smaller type for size/capacity")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
parent
6ae88a0b90
commit
0282abb0e6
@ -367,8 +367,9 @@ static bool vector##_empty(const struct vector *vector) \
|
||||
} \
|
||||
\
|
||||
static const vector##_size_type vector##_max_size = \
|
||||
min_iconst(PTRDIFF_MAX, (vector##_size_type)-1) \
|
||||
/ sizeof(vector##_entry_type); \
|
||||
/* The redundant cast works around llvm/llvm-project#38137. */ \
|
||||
(vector##_size_type)min_iconst(PTRDIFF_MAX / sizeof(vector##_entry_type),\
|
||||
(vector##_size_type)-1); \
|
||||
\
|
||||
static vector##_size_type vector##_capacity(const struct vector *vector) \
|
||||
{ \
|
||||
|
Loading…
Reference in New Issue
Block a user