From 401ff6994d842a4072b7b155e5a958e178e6497a Mon Sep 17 00:00:00 2001 From: Eric Herman Date: Fri, 3 Sep 2021 06:38:54 +0200 Subject: MDEV-26221: DYNAMIC_ARRAY use size_t for sizes https://jira.mariadb.org/browse/MDEV-26221 my_sys DYNAMIC_ARRAY and DYNAMIC_STRING inconsistancy The DYNAMIC_STRING uses size_t for sizes, but DYNAMIC_ARRAY used uint. This patch adjusts DYNAMIC_ARRAY to use size_t like DYNAMIC_STRING. As the MY_DIR member number_of_files is copied from a DYNAMIC_ARRAY, this is changed to be size_t. As MY_TMPDIR members 'cur' and 'max' are copied from a DYNAMIC_ARRAY, these are also changed to be size_t. The lists of plugins and stored procedures use DYNAMIC_ARRAY, but their APIs assume a size of 'uint'; these are unchanged. --- sql/sql_array.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sql/sql_array.h') diff --git a/sql/sql_array.h b/sql/sql_array.h index 0995653e1d7..85a53ae1a6f 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -114,19 +114,19 @@ template class Dynamic_array { DYNAMIC_ARRAY array; public: - Dynamic_array(PSI_memory_key psi_key, uint prealloc=16, uint increment=16) + Dynamic_array(PSI_memory_key psi_key, size_t prealloc=16, size_t increment=16) { init(psi_key, prealloc, increment); } - Dynamic_array(MEM_ROOT *root, uint prealloc=16, uint increment=16) + Dynamic_array(MEM_ROOT *root, size_t prealloc=16, size_t increment=16) { void *init_buffer= alloc_root(root, sizeof(Elem) * prealloc); init_dynamic_array2(root->psi_key, &array, sizeof(Elem), init_buffer, prealloc, increment, MYF(0)); } - void init(PSI_memory_key psi_key, uint prealloc=16, uint increment=16) + void init(PSI_memory_key psi_key, size_t prealloc=16, size_t increment=16) { init_dynamic_array2(psi_key, &array, sizeof(Elem), 0, prealloc, increment, MYF(0)); } @@ -217,7 +217,7 @@ public: void del(size_t idx) { DBUG_ASSERT(idx <= array.max_element); - delete_dynamic_element(&array, (uint)idx); + delete_dynamic_element(&array, idx); } size_t elements() const @@ -228,7 +228,7 @@ public: void elements(size_t num_elements) { DBUG_ASSERT(num_elements <= array.max_element); - array.elements= (uint)num_elements; + array.elements= num_elements; } void clear() @@ -236,7 +236,7 @@ public: elements(0); } - void set(uint idx, const Elem &el) + void set(size_t idx, const Elem &el) { set_dynamic(&array, &el, idx); } @@ -248,7 +248,7 @@ public: bool reserve(size_t new_size) { - return allocate_dynamic(&array, (uint)new_size); + return allocate_dynamic(&array, new_size); } @@ -260,7 +260,7 @@ public: if (new_size > old_size) { - set_dynamic(&array, (uchar*)&default_val, (uint)(new_size - 1)); + set_dynamic(&array, (uchar*)&default_val, new_size - 1); /*for (size_t i= old_size; i != new_size; i++) { at(i)= default_val; -- cgit v1.2.1