Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB

  1. /*===========================================================================
  2. xmlpool.h
  3. Based heavily on alloc-pool.c in gcc (some old code)
  4. TODO
  5. - String interning (wraps xmlpool object?)
  6. - Automatically free blocks when all items are unused (in XMLPool_Free)
  7. Add itemsAllocatedThisBlock tracking var to headers?
  8. ===========================================================================*/
  9. #ifndef XMLPOOL__H
  10. #define XMLPOOL__H
  11. #include <stddef.h>
  12. #ifndef XMLAPI
  13. #define XMLAPI
  14. #endif
  15. typedef struct tagLPXMLPOOLLIST
  16. {
  17. struct tagLPXMLPOOLLIST *next;
  18. } *LPXMLPOOLLIST;
  19. typedef struct tagLPXMLPOOL
  20. {
  21. int itemSize;
  22. int itemsPerBlock;
  23. int itemsAllocated;
  24. int itemsFree;
  25. int blocksAllocated;
  26. int blockSize;
  27. LPXMLPOOLLIST freeList;
  28. LPXMLPOOLLIST blockList;
  29. } *LPXMLPOOL;
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. LPXMLPOOL XMLAPI XMLPool_Create(int itemSize, int itemsPerBlock);
  34. void XMLAPI XMLPool_FreePool(LPXMLPOOL pool);
  35. void XMLAPI *XMLPool_Alloc(LPXMLPOOL pool);
  36. void XMLAPI XMLPool_Free(LPXMLPOOL pool, void *ptr);
  37. #ifdef __cplusplus
  38. }
  39. #endif /* __cplusplus */
  40. #endif /* XMLPOOL__H */