summaryrefslogtreecommitdiff
path: root/mysys/queues.c
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2003-10-06 14:11:16 +0200
committerunknown <serg@serg.mylan>2003-10-06 14:11:16 +0200
commit08a08a67dbde78258e46b0d9bcd387c8419b8fcd (patch)
tree7bffd47192fc8d22df42f124ba543de3125a5375 /mysys/queues.c
parent08504cfe276a2ff53ab34a13250220c28702e03c (diff)
downloadmariadb-git-08a08a67dbde78258e46b0d9bcd387c8419b8fcd.tar.gz
fix_max_connections to resize alarm_queue (Bug #1435)
include/queues.h: resize_queue() include/thr_alarm.h: resize_thr_alarm() to resize alarm_queue mysys/queues.c: resize_queue() mysys/thr_alarm.c: resize_thr_alarm() to resize alarm_queue
Diffstat (limited to 'mysys/queues.c')
-rw-r--r--mysys/queues.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/mysys/queues.c b/mysys/queues.c
index fe642131d74..ae69684f9e4 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -44,25 +44,35 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
}
/*
- Reinitialize queue for new usage; Note that you can't currently resize
- the number of elements! If you need this, fix it :)
+ Reinitialize queue for new usage;
*/
-
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
pbool max_at_top, int (*compare) (void *, byte *, byte *),
void *first_cmp_arg)
{
DBUG_ENTER("reinit_queue");
- if (queue->max_elements < max_elements)
- /* It's real easy to do realloc here, just don't want to bother */
- DBUG_RETURN(my_errno=EE_OUTOFMEMORY);
-
queue->elements=0;
queue->compare=compare;
queue->first_cmp_arg=first_cmp_arg;
queue->offset_to_key=offset_to_key;
queue->max_at_top= max_at_top ? (-1 ^ 1) : 0;
+ resize_queue(queue, max_elements);
+ DBUG_RETURN(0);
+}
+
+int resize_queue(QUEUE *queue, uint max_elements)
+{
+ byte **new_root;
+ DBUG_ENTER("resize_queue");
+ if (queue->max_elements == max_elements)
+ DBUG_RETURN(0);
+ if ((new_root= (byte **) my_realloc((void *)queue->root,
+ (max_elements+1)*sizeof(void*), MYF(MY_WME))) == 0)
+ DBUG_RETURN(1);
+ set_if_smaller(queue->elements, max_elements);
+ queue->max_elements=max_elements;
+ queue->root=new_root;
DBUG_RETURN(0);
}