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.

60 lines
651 B

  1. #include "node.h"
  2. #include "lfmp.h"
  3. static lfmp_t g_NODE_FMP;
  4. static
  5. __attribute__((constructor))
  6. void
  7. node_constructor()
  8. {
  9. lfmp_init(&g_NODE_FMP,sizeof(node_t),256);
  10. }
  11. static
  12. __attribute__((destructor))
  13. void
  14. node_destructor()
  15. {
  16. lfmp_destroy(&g_NODE_FMP);
  17. }
  18. node_t *
  19. node_alloc()
  20. {
  21. return lfmp_calloc(&g_NODE_FMP);
  22. }
  23. void
  24. node_free(node_t *node_)
  25. {
  26. lfmp_free(&g_NODE_FMP,node_);
  27. }
  28. int
  29. node_gc1()
  30. {
  31. return lfmp_gc(&g_NODE_FMP);
  32. }
  33. void
  34. node_gc()
  35. {
  36. int rv;
  37. int fails;
  38. fails = 0;
  39. do
  40. {
  41. rv = node_gc1();
  42. if(rv == 0)
  43. fails++;
  44. } while(rv || (fails < 3));
  45. }
  46. lfmp_t*
  47. node_lfmp()
  48. {
  49. return &g_NODE_FMP;
  50. }