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.

mem_pool.h 839B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef RSPAMD_MEM_POOL_H
  2. #define RSPAMD_MEM_POOL_H
  3. #include <sys/types.h>
  4. #include <glib.h>
  5. struct _pool_chain {
  6. u_char *begin;
  7. u_char *pos;
  8. size_t len;
  9. struct _pool_chain *next;
  10. };
  11. typedef struct memory_pool_s {
  12. struct _pool_chain *cur_pool;
  13. struct _pool_chain *first_pool;
  14. } memory_pool_t;
  15. typedef struct memory_pool_stat_s {
  16. size_t bytes_allocated;
  17. size_t chunks_allocated;
  18. size_t chunks_freed;
  19. } memory_pool_stat_t;
  20. memory_pool_t* memory_pool_new (size_t size);
  21. void* memory_pool_alloc (memory_pool_t* pool, size_t size);
  22. void* memory_pool_alloc0 (memory_pool_t* pool, size_t size);
  23. char* memory_pool_strdup (memory_pool_t* pool, const char *src);
  24. void memory_pool_delete (memory_pool_t* pool);
  25. void memory_pool_stat (memory_pool_stat_t *st);
  26. #define memory_pool_free(x) ((x)->len - ((x)->pos - (x)->begin))
  27. #endif