8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-01 19:20:38 +01:00
firebird-mirror/src/alice/all.cpp

148 lines
3.6 KiB
C++
Raw Normal View History

2001-05-23 15:26:42 +02:00
//____________________________________________________________
//
// PROGRAM: Alice (All Else) Utility
// MODULE: all.cpp
// DESCRIPTION: Block allocator
//
// 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
//
// 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.
//
// The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation.
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
//
//
//____________________________________________________________
//
// $Id: all.cpp,v 1.28 2004-08-30 18:10:28 alexpeshkoff Exp $
2001-05-23 15:26:42 +02:00
//
#include "firebird.h"
2004-05-15 02:58:46 +02:00
#include "../jrd/common.h"
2003-12-14 19:26:25 +01:00
#include "../alice/all.h"
2001-12-24 03:51:06 +01:00
#include "../alice/alice.h"
#include "../jrd/thd.h"
#include "../common/classes/alloc.h"
2001-05-23 15:26:42 +02:00
#ifdef NOT_USED_OR_REPLACED
void AliceMemoryPool::ALLA_push(blk* object, alice_lls** stack)
2001-05-23 15:26:42 +02:00
{
2001-12-24 03:51:06 +01:00
/**************************************
*
* A L L _ p u s h
*
**************************************
*
* Functional description
* Push an object on an LLS stack.
*
**************************************/
2004-07-02 12:02:46 +02:00
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
AliceMemoryPool* pool = tdgbl->ALICE_default_pool;
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
alice_lls* node = pool->lls_cache.newBlock();
2001-05-23 15:26:42 +02:00
node->lls_object = object;
node->lls_next = *stack;
*stack = node;
}
2004-02-02 12:02:12 +01:00
BLK AliceMemoryPool::ALLA_pop(alice_lls** stack)
2001-05-23 15:26:42 +02:00
{
2001-12-24 03:51:06 +01:00
/**************************************
*
* A L L _ p o p
*
**************************************
*
* Functional description
* Pop an object off a linked list stack. Save the node for
* further use.
*
**************************************/
2004-02-02 12:02:12 +01:00
alice_lls* node = *stack;
2001-05-23 15:26:42 +02:00
*stack = node->lls_next;
BLK object = node->lls_object;
2001-05-23 15:26:42 +02:00
AliceMemoryPool* pool = (AliceMemoryPool*)MemoryPool::blk _pool(node);
2001-12-24 03:51:06 +01:00
pool->lls_cache.returnBlock(node);
2001-05-23 15:26:42 +02:00
2001-12-24 03:51:06 +01:00
return object;
2001-05-23 15:26:42 +02:00
}
2001-12-24 03:51:06 +01:00
AliceMemoryPool* AliceMemoryPool::create_new_pool(MemoryPool* parent)
2001-05-23 15:26:42 +02:00
{
2001-12-24 03:51:06 +01:00
/**************************************
*
* A L L _ p o o l
*
**************************************
*
* Functional description
* Allocate a new pool.
*
**************************************/
2004-07-02 12:02:46 +02:00
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
2001-12-24 03:51:06 +01:00
// TMN: John, is this correct?
AliceMemoryPool* pool = new(0, parent) AliceMemoryPool(parent);
2004-07-03 02:13:46 +02:00
AliceGlobals::pool_vec_t::iterator curr;
2001-12-24 03:51:06 +01:00
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
2001-12-24 03:51:06 +01:00
{
if (!*curr)
{
*curr = pool;
return pool;
}
2001-05-23 15:26:42 +02:00
}
2001-12-24 03:51:06 +01:00
tdgbl->pools.resize(tdgbl->pools.size() + 10);
for (curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
2001-12-24 03:51:06 +01:00
{
if (!*curr)
{
*curr = pool;
return pool;
}
2001-05-23 15:26:42 +02:00
}
2003-11-04 00:59:24 +01:00
//fb_assert(0);
2001-12-24 03:51:06 +01:00
//BUGCHECK ("ALLA_fini - finishing before starting");
return 0;//pool; // Never reached, but makes the compiler happy.
2001-05-23 15:26:42 +02:00
}
#endif //NOT_USED_OR_REPLACED
AliceMemoryPool* AliceMemoryPool::createPool() {
AliceMemoryPool* result = (AliceMemoryPool*)internal_create(sizeof(AliceMemoryPool));
AliceGlobals::getSpecific()->pools.add(result);
return result;
}
2001-05-23 15:26:42 +02:00
void AliceMemoryPool::deletePool(AliceMemoryPool* pool)
{
2004-07-02 12:02:46 +02:00
AliceGlobals* tdgbl = AliceGlobals::getSpecific();
2001-12-24 03:51:06 +01:00
for (int i = 0; i < tdgbl->pools.getCount(); ++i)
2001-12-24 03:51:06 +01:00
{
if (tdgbl->pools[i] == pool)
2001-12-24 03:51:06 +01:00
{
tdgbl->pools.remove(i);
break;
2001-12-24 03:51:06 +01:00
}
2001-05-23 15:26:42 +02:00
}
MemoryPool::deletePool(pool);
2001-05-23 15:26:42 +02:00
}