diff --git a/src/common/classes/array.h b/src/common/classes/array.h index 48a9c6867a..bf4a2deda2 100644 --- a/src/common/classes/array.h +++ b/src/common/classes/array.h @@ -133,7 +133,7 @@ public: memmove(data + index + 1, data + index, sizeof(T) * (count++ - index)); data[index] = item; } - void insert(int index, Array& L) { + void insert(int index, const Array& L) { fb_assert(index >= 0 && index <= count); ensureCapacity(count + L.count); memmove(data + index + L.count, data + index, sizeof(T) * (count - index)); diff --git a/src/common/classes/objects_array.h b/src/common/classes/objects_array.h index c07877ace3..933c89f2a2 100644 --- a/src/common/classes/objects_array.h +++ b/src/common/classes/objects_array.h @@ -47,11 +47,13 @@ namespace Firebird iterator(ObjectsArray *l, int p) : lst(l), pos(p) { } public: iterator() : lst(0), pos(0) { } +/* iterator& operator=(ObjectsArray& a) { - lst = a.l; + lst = &a; pos = 0; } + */ iterator& operator++() {++pos; return (*this);} iterator operator++(int) {iterator tmp = *this; ++pos; return tmp;} diff --git a/src/common/classes/stack.h b/src/common/classes/stack.h index 8ff1161d90..2867cda33c 100644 --- a/src/common/classes/stack.h +++ b/src/common/classes/stack.h @@ -3,24 +3,25 @@ * MODULE: stack.h * DESCRIPTION: Stack. * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. + * Software distributed under the License is distributed AS IS, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. + * See the License for the specific language governing rights + * and limitations under the License. * - * Stack is implemented as a linked list of vectors. - * This makes implementation of merge and split operations - * enough efficcient for large stacks (used in opt.cpp). + * The Original Code was created by Alexander Peshkoff + * for the Firebird Open Source RDBMS project. * - * Created by: Alex Peshkov + * Copyright (c) 2004 Alexander Peshkoff + * and all contributors signed below. * - * All Rights Reserved. - * Contributor(s): ______________________________________. + * All Rights Reserved. + * Contributor(s): ______________________________________. * */ @@ -80,6 +81,7 @@ namespace Firebird { void split(int elem, Entry* target) { + fb_assert(elem > 0 && elem < count); memcpy(target->data, data, elem * sizeof(Object)); target->count += elem; count -= elem; @@ -126,12 +128,15 @@ namespace Firebird { return tmp; } - Stack& operator= (Stack& s) { + private: + Stack& operator= (Stack& s); + + public: + void takeOwnership (Stack& s) { fb_assert(&getPool() == &s.getPool()); delete stk; stk = s.stk; s.stk = 0; - return *this; } class iterator { @@ -151,7 +156,7 @@ namespace Firebird { { fb_assert(stk); if (--elem <= 0) { - if ((stk = stk->next)) + if ((stk = stk->next)) { elem = stk->getCount(); } diff --git a/src/jrd/opt.cpp b/src/jrd/opt.cpp index f7a399d51c..4409a82163 100644 --- a/src/jrd/opt.cpp +++ b/src/jrd/opt.cpp @@ -5247,7 +5247,7 @@ static bool gen_sort_merge(thread_db* tdbb, OptimizerBlk* opt, RiverStack& org_r river1->riv_rsb = gen_boolean(tdbb, opt, river1->riv_rsb, node); } set_inactive(opt, river1); - org_rivers = newRivers; + org_rivers.takeOwnership(newRivers); for (stream_nr = 0, fv = flag_vector; stream_nr < opt->opt_csb->csb_n_stream; stream_nr++)