arrayalloc.h 898 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef ARRAYALLOC_H
  2. #define ARRAYALLOC_H 1
  3. #include "../libnetdata.h"
  4. typedef struct arrayalloc {
  5. size_t element_size;
  6. size_t elements;
  7. const char *filename;
  8. char **cache_dir;
  9. bool use_mmap;
  10. // private members - do not touch
  11. struct {
  12. bool mmap;
  13. bool lockless;
  14. bool initialized;
  15. size_t element_size;
  16. size_t page_ptr_offset;
  17. size_t file_number;
  18. size_t natural_page_size;
  19. size_t allocation_multiplier;
  20. size_t max_alloc_size;
  21. netdata_mutex_t mutex;
  22. struct arrayalloc_page *first_page;
  23. struct arrayalloc_page *last_page;
  24. } internal;
  25. } ARAL;
  26. extern ARAL *arrayalloc_create(size_t element_size, size_t elements, const char *filename, char **cache_dir);
  27. extern void *arrayalloc_mallocz(ARAL *ar);
  28. extern void arrayalloc_freez(ARAL *ar, void *ptr);
  29. #endif // ARRAYALLOC_H