mem_pool_base.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  2. // vim:tabstop=4:shiftwidth=4:expandtab:
  3. /*
  4. * Copyright (C) 2004-2008 Wu Yongwei <adah at users dot sourceforge dot net>
  5. *
  6. * This software is provided 'as-is', without any express or implied
  7. * warranty. In no event will the authors be held liable for any
  8. * damages arising from the use of this software.
  9. *
  10. * Permission is granted to anyone to use this software for any purpose,
  11. * including commercial applications, and to alter it and redistribute
  12. * it freely, subject to the following restrictions:
  13. *
  14. * 1. The origin of this software must not be misrepresented; you must
  15. * not claim that you wrote the original software. If you use this
  16. * software in a product, an acknowledgement in the product
  17. * documentation would be appreciated but is not required.
  18. * 2. Altered source versions must be plainly marked as such, and must
  19. * not be misrepresented as being the original software.
  20. * 3. This notice may not be removed or altered from any source
  21. * distribution.
  22. *
  23. * This file is part of Stones of Nvwa:
  24. * http://sourceforge.net/projects/nvwa
  25. *
  26. */
  27. /*!
  28. * \file mem_pool_base.h
  29. * \ingroup QxMemLeak
  30. *
  31. * Header file for the memory pool base.
  32. *
  33. * \version 1.1, 2004/07/26
  34. * \author Wu Yongwei
  35. *
  36. */
  37. #ifndef QT_NO_DEBUG
  38. #ifndef _QX_MODE_RELEASE
  39. #if _QX_USE_MEM_LEAK_DETECTION
  40. #ifndef _MEM_POOL_BASE_H
  41. #define _MEM_POOL_BASE_H
  42. #ifdef _MSC_VER
  43. #pragma once
  44. #endif
  45. #include <stddef.h>
  46. namespace qx {
  47. namespace memory {
  48. /**
  49. * Base class for memory pools.
  50. */
  51. class QX_DLL_EXPORT mem_pool_base
  52. {
  53. public:
  54. virtual ~mem_pool_base();
  55. virtual void recycle() = 0;
  56. static void* alloc_sys(size_t __size);
  57. static void dealloc_sys(void* __ptr);
  58. /** Structure to store the next available memory block. */
  59. struct _Block_list { _Block_list* _M_next; };
  60. };
  61. } // namespace memory
  62. } // namespace qx
  63. #endif // _MEM_POOL_BASE_H
  64. #endif // _QX_USE_MEM_LEAK_DETECTION
  65. #endif // _QX_MODE_RELEASE
  66. #endif // QT_NO_DEBUG