gl_mempool.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef _GL_MEMPOOL_H_
  2. #define _GL_MEMPOOL_H_
  3. #include "gl_types.h"
  4. /******************************************************************************/
  5. /*!
  6. * @brief To create a variable size memory pool which is for allocating blocks of any size.
  7. *
  8. * @param szName String identifier for the Mempool.
  9. * @param pos The memory base of Mempool
  10. * @param size The max size of Mempool
  11. * @param pMempool Mempool object identifier returned by the API (on success)
  12. *
  13. * @return @a GL_SUCCESS on success
  14. * @return @a GL_FAILURE on failure
  15. *
  16. * @note None
  17. *******************************************************************************/
  18. GL_Status_t GL_MempoolVarCreate(char *szName, void *pos, GL_UINT32 size,
  19. GL_MEMPOOL_t *pMempool);
  20. /******************************************************************************/
  21. /*!
  22. * @brief To delete a Mempool. Regarding tasks waiting on a deleted, the behavior depends on the underlying OS; the GSL does not guarantee a default behavior (hence, applications should avoid this scenario). Typically, an error is returned to the waiting tasks.
  23. *
  24. * @param pMempool Mempool object identifier returned by the API
  25. *
  26. * @return @a GL_SUCCESS on success
  27. * @return @a GL_FAILURE on failure
  28. *
  29. * @note None
  30. *******************************************************************************/
  31. void GL_MempoolVarDestroy(GL_MEMPOOL_t pMempool);
  32. /******************************************************************************/
  33. /*!
  34. * @brief To allocate a buffer in mempool and if empty, it blocks until memory allocation is successful.
  35. *
  36. * @param pMempool Mempool object identifier returned by the API
  37. * @param dSize Size of buffer to allocatedFlags: Supported flags can be ORed together.
  38. * @param sdTimeout Timeout period to wait for memory allocation. Measured in milliseconds. Set to:
  39. * @li @a GL_INFINITE_WAIT for inifinite waiting
  40. * @li @a GL_NO_WAIT (Any value between 1-2147483647 for finite wait)
  41. *
  42. * @return Data pointer on SUCCESS. @a NULL (null pointer) on failure
  43. *
  44. * @note None
  45. *******************************************************************************/
  46. void * GL_MempoolVarAlloc(GL_MEMPOOL_t pMempool, GL_UINT32 dSize, GL_UINT32 sdTimeout);
  47. /******************************************************************************/
  48. /*!
  49. * @brief To release a buffer which is allocated by GL_MempoolVarAlloc
  50. *
  51. * @param pMempool Mempool object identifier returned by the API
  52. * @param p Pointor to mem alloced in mempool
  53. *
  54. * @return void
  55. *
  56. * @note None
  57. *******************************************************************************/
  58. void GL_MempoolVarFree(GL_MEMPOOL_t pMempool, void *p);
  59. #endif //_GL_MEMPOOL_H_