home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kvmallocator.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.4 KB  |  120 lines

  1. /*
  2.     This file is part of the KDE libraries
  3.  
  4.     Copyright (C) 2000 Waldo Bastian (bastian@kde.org)
  5.               
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21. //----------------------------------------------------------------------------
  22. //
  23. // KDE Virtual Memory Allocator
  24.  
  25. #ifndef KVMALLOCATOR_H
  26. #define KVMALLOCATOR_H
  27.  
  28. #include <sys/types.h>
  29. #include "kdelibs_export.h"
  30.  
  31. class KVMAllocatorPrivate;
  32.  
  33. /**
  34.  * KVMAllocator is a virtual memory allocator.
  35.  * Memory is allocated block-wise in a tmp file.
  36.  * 
  37.  * @author Waldo Bastian <bastian@kde.org>
  38.  */
  39. class KDECORE_EXPORT KVMAllocator
  40. {
  41. public:
  42.     struct Block;
  43.  
  44.     /**
  45.      * Create a KVMAllocator 
  46.      */
  47.     KVMAllocator();
  48.  
  49.     /**
  50.      * Destruct the KVMAllocator and release all memory.
  51.      */
  52.     ~KVMAllocator();
  53.  
  54.     /**
  55.      * Allocate a virtual memory block.
  56.      * @param _size Size in bytes of the memory block.
  57.      * @return the allocated memory block
  58.      */
  59.     Block *allocate(size_t _size);
  60.     
  61.     /**
  62.      * Free a virtual memory block.
  63.      * @param block the block to free
  64.      */
  65.     void free(Block *block);
  66.     
  67.     /**
  68.      * Copy @p length bytes from @p _offset in the virtual memory block 
  69.      * @p src to normal memory at address *dest.
  70.      * @param dest the destination of the data
  71.      * @param src the source block
  72.      * @param _offset the offset in the source block
  73.      * @param length the length of the data to copy
  74.      * @return true on success, false on failure, see errno for details
  75.      * @since 3.2
  76.      */
  77.     bool copyBlock(void *dest, Block *src, int _offset = 0, size_t length = 0);
  78.  
  79.     /**
  80.      * @deprecated
  81.      * @see copyBlock
  82.      */
  83.     void copy(void *dest, Block *src, int _offset = 0, size_t length = 0) KDE_DEPRECATED;
  84.      
  85.     /**
  86.      * Copy @p length bytes from normal memory at address @p src to 
  87.      * @p _offset in the virtual memory block @p dest.
  88.      * @param dest the block to copy the data to
  89.      * @param src the source location of the data
  90.      * @param _offset the offset in the destination block
  91.      * @param length the length of the data to copy
  92.      * @return true on success, false on failure, see errno for details
  93.      * @since 3.2
  94.      */
  95.     bool copyBlock(Block *dest, void *src, int _offset = 0, size_t length = 0);
  96.  
  97.     /**
  98.      * @deprecated
  99.      * @see copyBlock
  100.      */
  101.     void copy(Block *dest, void *src, int _offset = 0, size_t length = 0) KDE_DEPRECATED;  
  102.  
  103.     /**
  104.      * Map a virtual memory block in memory
  105.      * @param block the block to map
  106.      */
  107.     void *map(Block *block);
  108.     
  109.     /**
  110.      * Unmap a virtual memory block
  111.      * @param block the block to unmap
  112.      */
  113.     void unmap(Block *block);
  114.     
  115. private:
  116.     KVMAllocatorPrivate *d;
  117. };
  118.  
  119. #endif
  120.