Rename KZone to avoid conflicts with KDE4

pull/16/head
Timothy Pearson 12 years ago
parent c675be6f89
commit a07501e296

@ -30,7 +30,7 @@
#include "kallocator.h" #include "kallocator.h"
#include <kdebug.h> #include <kdebug.h>
class KZoneAllocator::MemBlock class TDEZoneAllocator::MemBlock
{ {
public: public:
MemBlock(size_t s) : size(s), ref(0), older(0), newer(0) MemBlock(size_t s) : size(s), ref(0), older(0), newer(0)
@ -45,7 +45,7 @@ class KZoneAllocator::MemBlock
MemBlock *newer; MemBlock *newer;
}; };
KZoneAllocator::KZoneAllocator(unsigned long _blockSize) TDEZoneAllocator::TDEZoneAllocator(unsigned long _blockSize)
: currentBlock(0), blockSize(1), blockOffset(0), log2(0), num_blocks(0), : currentBlock(0), blockSize(1), blockOffset(0), log2(0), num_blocks(0),
hashList(0), hashSize(0), hashDirty(true) hashList(0), hashSize(0), hashDirty(true)
{ {
@ -56,7 +56,7 @@ KZoneAllocator::KZoneAllocator(unsigned long _blockSize)
blockOffset = blockSize + 1; blockOffset = blockSize + 1;
} }
KZoneAllocator::~KZoneAllocator() TDEZoneAllocator::~TDEZoneAllocator()
{ {
unsigned int count = 0; unsigned int count = 0;
if (hashList) { if (hashList) {
@ -80,7 +80,7 @@ KZoneAllocator::~KZoneAllocator()
#endif #endif
} }
void KZoneAllocator::insertHash(MemBlock *b) void TDEZoneAllocator::insertHash(MemBlock *b)
{ {
unsigned long adr = ((unsigned long)b->begin) & (~(blockSize - 1)); unsigned long adr = ((unsigned long)b->begin) & (~(blockSize - 1));
unsigned long end = ((unsigned long)b->begin) + blockSize; unsigned long end = ((unsigned long)b->begin) + blockSize;
@ -99,7 +99,7 @@ void KZoneAllocator::insertHash(MemBlock *b)
@param b block to add @param b block to add
@internal @internal
*/ */
void KZoneAllocator::addBlock(MemBlock *b) void TDEZoneAllocator::addBlock(MemBlock *b)
{ {
b->newer = 0; b->newer = 0;
b->older = currentBlock; b->older = currentBlock;
@ -119,7 +119,7 @@ void KZoneAllocator::addBlock(MemBlock *b)
} }
/** Reinitialize hash list. @internal */ /** Reinitialize hash list. @internal */
void KZoneAllocator::initHash() void TDEZoneAllocator::initHash()
{ {
if (hashList) { if (hashList) {
for (unsigned int i = 0; i < hashSize; i++) for (unsigned int i = 0; i < hashSize; i++)
@ -145,7 +145,7 @@ void KZoneAllocator::initHash()
@param b block to delete @param b block to delete
@internal @internal
*/ */
void KZoneAllocator::delBlock(MemBlock *b) void TDEZoneAllocator::delBlock(MemBlock *b)
{ {
/* Update also the hashlists if we aren't going to reconstruct them /* Update also the hashlists if we aren't going to reconstruct them
soon. */ soon. */
@ -181,7 +181,7 @@ void KZoneAllocator::delBlock(MemBlock *b)
} }
void * void *
KZoneAllocator::allocate(size_t _size) TDEZoneAllocator::allocate(size_t _size)
{ {
// Use the size of (void *) as alignment // Use the size of (void *) as alignment
const size_t alignment = sizeof(void *) - 1; const size_t alignment = sizeof(void *) - 1;
@ -190,7 +190,7 @@ KZoneAllocator::allocate(size_t _size)
if ((unsigned long) _size + blockOffset > blockSize) if ((unsigned long) _size + blockOffset > blockSize)
{ {
if (_size > blockSize) { if (_size > blockSize) {
tqDebug("KZoneAllocator: allocating more than %lu bytes", blockSize); tqDebug("TDEZoneAllocator: allocating more than %lu bytes", blockSize);
return 0; return 0;
} }
addBlock(new MemBlock(blockSize)); addBlock(new MemBlock(blockSize));
@ -204,7 +204,7 @@ KZoneAllocator::allocate(size_t _size)
} }
void void
KZoneAllocator::deallocate(void *ptr) TDEZoneAllocator::deallocate(void *ptr)
{ {
if (hashDirty) if (hashDirty)
initHash(); initHash();
@ -237,7 +237,7 @@ KZoneAllocator::deallocate(void *ptr)
} }
void void
KZoneAllocator::free_since(void *ptr) TDEZoneAllocator::free_since(void *ptr)
{ {
/* If we have a hashList and it's not yet dirty, see, if we will dirty /* If we have a hashList and it's not yet dirty, see, if we will dirty
it by removing too many blocks. This will make the below delBlock()s it by removing too many blocks. This will make the below delBlock()s

@ -29,7 +29,7 @@
#include <tqvaluelist.h> #include <tqvaluelist.h>
#include "tdelibs_export.h" #include "tdelibs_export.h"
class KZoneAllocatorPrivate; class TDEZoneAllocatorPrivate;
/** /**
@ -43,19 +43,19 @@ class KZoneAllocatorPrivate;
* memory though. * memory though.
* @author Waldo Bastian <bastian@kde.org>, Michael Matz <matz@kde.org> * @author Waldo Bastian <bastian@kde.org>, Michael Matz <matz@kde.org>
*/ */
class TDECORE_EXPORT KZoneAllocator class TDECORE_EXPORT TDEZoneAllocator
{ {
public: public:
/** /**
* Creates a KZoneAllocator object. * Creates a TDEZoneAllocator object.
* @param _blockSize Size in bytes of the blocks requested from malloc. * @param _blockSize Size in bytes of the blocks requested from malloc.
*/ */
KZoneAllocator(unsigned long _blockSize = 8*1024); TDEZoneAllocator(unsigned long _blockSize = 8*1024);
/** /**
* Destructs the ZoneAllocator and free all memory allocated by it. * Destructs the ZoneAllocator and free all memory allocated by it.
*/ */
~KZoneAllocator(); ~TDEZoneAllocator();
/** /**
* Allocates a memory block. * Allocates a memory block.
@ -78,7 +78,7 @@ public:
* more time then the normal calls, and that after this list is built, i.e. * more time then the normal calls, and that after this list is built, i.e.
* generally if deallocate() is used at all, also allocate() is a * generally if deallocate() is used at all, also allocate() is a
* little bit slower. This means, that if you want to squeeze out the last * little bit slower. This means, that if you want to squeeze out the last
* bit performance you would want to use KZoneAllocator as an obstack, i.e. * bit performance you would want to use TDEZoneAllocator as an obstack, i.e.
* just use the functions allocate() and free_since(). All the * just use the functions allocate() and free_since(). All the
* remaining memory is returned to the system if the zone allocator * remaining memory is returned to the system if the zone allocator
* is destroyed. * is destroyed.
@ -93,7 +93,7 @@ public:
* *
* The intended use is something along the lines of: * The intended use is something along the lines of:
* \code * \code
* KZoneAllocator alloc(8192); * TDEZoneAllocator alloc(8192);
* void *remember_me = alloc.allocate(0); * void *remember_me = alloc.allocate(0);
* for (int i = 0; i < 1000; i++) * for (int i = 0; i < 1000; i++)
* do_something_with (alloc.allocate(12)); * do_something_with (alloc.allocate(12));
@ -134,7 +134,7 @@ protected:
/** Flag the hashes as in need of reorganization. @internal */ /** Flag the hashes as in need of reorganization. @internal */
bool hashDirty; bool hashDirty;
private: private:
KZoneAllocatorPrivate *d; TDEZoneAllocatorPrivate *d;
}; };
#endif #endif

@ -881,7 +881,7 @@ KCompTreeNode *KCompTreeNodeList::at(uint index) const
return cur; return cur;
} }
KZoneAllocator KCompTreeNode::alloc(8192); TDEZoneAllocator KCompTreeNode::alloc(8192);
void KCompletion::virtual_hook( int, void* ) void KCompletion::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ } { /*BASE::virtual_hook( id, data );*/ }

@ -135,7 +135,7 @@ public:
private: private:
uint myWeight; uint myWeight;
KCompTreeNodeList myChildren; KCompTreeNodeList myChildren;
static KZoneAllocator alloc; static TDEZoneAllocator alloc;
}; };

Loading…
Cancel
Save