summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorV Narayanan <v.narayanan@sun.com>2009-07-12 11:18:53 +0530
committerV Narayanan <v.narayanan@sun.com>2009-07-12 11:18:53 +0530
commitce0bf2a4759e176ac9992de750772ccd88feb48b (patch)
tree153af40da22e501f87e4a92c3a6117ecb34f61b6 /mysys
parent6a7240b8d71e8c003bb88b4f6afafdac820fb819 (diff)
downloadmariadb-git-ce0bf2a4759e176ac9992de750772ccd88feb48b.tar.gz
Bug#43572 Handle failures from hash_init
This patch is a follow up to http://lists.mysql.com/commits/76678. When an allocation failure occurs for the buffer in the dynamic array, an error condition was being set. The dynamic array is usable even if the memory allocation fails. Since in most cases the thread can continue to work without any problems the error condition should not be set here. This patch adds logic to remove the error condition from being set when the memory allocation for the buffer in dynamic array fails.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/array.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/mysys/array.c b/mysys/array.c
index 4ea1946d837..354508f05ef 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -31,10 +31,10 @@
DESCRIPTION
init_dynamic_array() initiates array and allocate space for
init_alloc eilements.
- Array is usable even if space allocation failed.
+ Array is usable even if space allocation failed, hence, the
+ function never returns TRUE.
RETURN VALUE
- TRUE my_malloc_ci() failed
FALSE Ok
*/
@@ -56,11 +56,12 @@ my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
array->max_element=init_alloc;
array->alloc_increment=alloc_increment;
array->size_of_element=element_size;
- if (!(array->buffer=(char*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME))))
- {
+ /*
+ Since the dynamic array is usable even if allocation fails here malloc
+ should not throw an error
+ */
+ if (!(array->buffer= (char*) my_malloc_ci(element_size*init_alloc, MYF(0))))
array->max_element=0;
- DBUG_RETURN(TRUE);
- }
DBUG_RETURN(FALSE);
}