summaryrefslogtreecommitdiff
path: root/mysys/array.c
diff options
context:
space:
mode:
authorEric Herman <eric@freesa.org>2021-09-03 06:38:54 +0200
committerVicențiu Ciorbaru <cvicentiu@gmail.com>2021-10-15 12:14:47 +0300
commit0649bcff4e984cb29d9fc12bde7eccb87ea7e38e (patch)
tree7459ff3efdcfdfa2ab4094f7ff5b7e5d4332e9a0 /mysys/array.c
parenta6cf8b34a834e5d16155f8bb3f33d57a4f87eb9e (diff)
downloadmariadb-git-bb-10.7-vicentiu.tar.gz
MDEV-26221: DYNAMIC_ARRAY use size_t for sizesbb-10.7-vicentiu
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.
Diffstat (limited to 'mysys/array.c')
-rw-r--r--mysys/array.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/mysys/array.c b/mysys/array.c
index 32606cafb23..c9bf609b6d4 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -41,8 +41,9 @@
*/
my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
- uint element_size, void *init_buffer,
- uint init_alloc, uint alloc_increment, myf my_flags)
+ size_t element_size, void *init_buffer,
+ size_t init_alloc, size_t alloc_increment,
+ myf my_flags)
{
DBUG_ENTER("init_dynamic_array2");
if (!alloc_increment)
@@ -198,7 +199,7 @@ void *pop_dynamic(DYNAMIC_ARRAY *array)
FALSE Ok
*/
-my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx)
+my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, size_t idx)
{
if (idx >= array->elements)
{
@@ -209,7 +210,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx)
array->elements=idx+1;
}
memcpy(array->buffer+(idx * array->size_of_element),element,
- (size_t) array->size_of_element);
+ array->size_of_element);
return FALSE;
}
@@ -230,13 +231,13 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx)
TRUE Allocation of new memory failed
*/
-my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
+my_bool allocate_dynamic(DYNAMIC_ARRAY *array, size_t max_elements)
{
DBUG_ENTER("allocate_dynamic");
if (max_elements >= array->max_element)
{
- uint size;
+ size_t size;
uchar *new_ptr;
size= (max_elements + array->alloc_increment)/array->alloc_increment;
size*= array->alloc_increment;
@@ -277,7 +278,7 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
idx Index of element wanted.
*/
-void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint idx)
+void get_dynamic(DYNAMIC_ARRAY *array, void *element, size_t idx)
{
if (idx >= array->elements)
{
@@ -320,7 +321,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array)
idx Index of element to be deleted
*/
-void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx)
+void delete_dynamic_element(DYNAMIC_ARRAY *array, size_t idx)
{
char *ptr= (char*) array->buffer+array->size_of_element*idx;
array->elements--;
@@ -339,7 +340,7 @@ void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx)
deleting the array;
*/
void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) {
- uint i;
+ size_t i;
char *ptr= (char*) array->buffer;
for (i= 0; i < array->elements; i++, ptr+= array->size_of_element) {
f(ptr);
@@ -357,7 +358,7 @@ void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) {
void freeze_size(DYNAMIC_ARRAY *array)
{
- uint elements;
+ size_t elements;
/*
Do nothing if we are using a static buffer