mem_pool.h 543 B

12345678910111213141516171819202122232425262728
  1. #ifndef MEM_POOL_H
  2. #define MEN_POOL_H
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <assert.h>
  7. #include <unistd.h>
  8. //#include <time.h>
  9. struct msg_pool {
  10. int max_size;
  11. void *data_ptr;
  12. int list_cnt;
  13. void *free_list;
  14. int free_cnt;
  15. struct msg_pool *next;
  16. };
  17. void* msg_pool_alloc(struct msg_pool* p, size_t size);
  18. struct msg_pool* create_pool(int max_size);
  19. void msg_pool_free(struct msg_pool *p, void *ptr, char* freed);
  20. void msg_pool_delete(struct msg_pool *p);
  21. #endif