From 08a08a67dbde78258e46b0d9bcd387c8419b8fcd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Oct 2003 14:11:16 +0200 Subject: 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 --- mysys/queues.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'mysys/queues.c') 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); } -- cgit v1.2.1