BufferAlloc.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. //////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  FileName    :   BufferAlloc.h
  4. //  Version     :   1.0
  5. //  Creater     :   Freeway Chen 
  6. //  Date        :   2003-6-26 15:03:30
  7. //  Comment     :   
  8. //
  9. //////////////////////////////////////////////////////////////////////////////////////
  10. #ifndef _BUFFERALLOC_H
  11. #define _BUFFERALLOC_H  1
  12. #include "windows.h"
  13. // ===================================================================================
  14. // 内部使用数据
  15. extern long g_lBufferAllocInitCount;
  16. int _BufferAlloc_Init_Internal();
  17. int _BufferAlloc_UnInit_Internal();
  18. // ===================================================================================
  19. // 对外的程序接口
  20. inline int BufferAlloc_Init()
  21. {
  22.     if (InterlockedIncrement(&g_lBufferAllocInitCount) == 1)
  23.     {
  24.         return _BufferAlloc_Init_Internal();
  25.     }
  26.     return true;
  27. }
  28. inline int BufferAlloc_UnInit()
  29. {
  30.     if (InterlockedDecrement(&g_lBufferAllocInitCount) == 0)
  31.     {
  32.         return _BufferAlloc_UnInit_Internal();
  33.     }
  34.     return true;
  35. }
  36. // 用来增加存放的最大空闲缓冲区的数目
  37. int BufferAlloc_IncMaxFreeNodeCount(long lCount);
  38. // 用来减少存放的最大空闲缓冲区的数目
  39. int BufferAlloc_DecMaxFreeNodeCount(long lCount);
  40. // 分配 uSize 大小的缓冲区
  41. void *BufferAlloc_Alloc(size_t uSize);
  42. // 释放 uSize 大小的缓冲区
  43. int BufferAlloc_Free(void *pvBuffer, size_t uSize);
  44. // ===================================================================================
  45. #endif  // _BUFFERALLOC_H