kallocator.h
/*
This file is part of the KDE libraries
Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
Copyright (C) 2002 Michael Matz (matz@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
//----------------------------------------------------------------------------
//
// KDE Memory Allocator
#ifndef KALLOCATOR_H
#define KALLOCATOR_H
#include <qvaluelist.h>
#include "kdelibs_export.h"
class KZoneAllocatorPrivate;
class KDECORE_EXPORT KZoneAllocator
{
public:
KZoneAllocator(unsigned long _blockSize = 8*1024);
~KZoneAllocator();
void* allocate(size_t _size);
void deallocate(void *ptr);
void free_since(void *ptr);
protected:
class MemBlock;
typedef QValueList<MemBlock *> MemList;
void addBlock(MemBlock *b);
void delBlock(MemBlock *b);
void insertHash(MemBlock *b);
void initHash();
MemBlock *currentBlock;
unsigned long blockSize;
unsigned long blockOffset;
unsigned int log2;
unsigned int num_blocks;
MemList **hashList;
unsigned int hashSize;
bool hashDirty;
private:
KZoneAllocatorPrivate *d;
};
#endif
KZoneAllocator::MemList
QValueList< MemBlock * > MemList
A list of chunks.
Definition: kallocator.h:113
KZoneAllocator::hashDirty
bool hashDirty
Flag the hashes as in need of reorganization.
Definition: kallocator.h:135
KZoneAllocator::log2
unsigned int log2
base-2 log of the block size.
Definition: kallocator.h:127
KZoneAllocator::currentBlock
MemBlock * currentBlock
One block is 'current' to satisfy requests.
Definition: kallocator.h:121
KZoneAllocator::num_blocks
unsigned int num_blocks
Count total number of allocated blocks.
Definition: kallocator.h:129
KZoneAllocator::blockSize
unsigned long blockSize
Store block size from constructor.
Definition: kallocator.h:123
KZoneAllocator
Memory allocator for large groups of small objects.
Definition: kallocator.h:46
KZoneAllocator::hashList
MemList ** hashList
Collection of lists of blocks, for lookups.
Definition: kallocator.h:131
KZoneAllocator::hashSize
unsigned int hashSize
Count of hashes.
Definition: kallocator.h:133
KZoneAllocator::blockOffset
unsigned long blockOffset
Store offset into current block; size-offset is free.
Definition: kallocator.h:125

KDE Home | KDE Accessibility Home | Description of Access Keys