1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

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.
This commit is contained in:
Eric Herman
2021-09-03 06:38:54 +02:00
committed by Vicențiu-Marian Ciorbaru
parent 9ab0d07e10
commit 401ff6994d
46 changed files with 188 additions and 191 deletions

View File

@ -114,19 +114,19 @@ template <class Elem> 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;