
#ifndef PLS_INCLUDE_PLS_INTERNAL_BASE_STACK_ALLOCATOR_H_
#define PLS_INCLUDE_PLS_INTERNAL_BASE_STACK_ALLOCATOR_H_

#include <cstddef>

namespace pls::internal::base {
class stack_allocator {
 public:
  virtual char *allocate_stack(size_t size) = 0;
  virtual void free_stack(size_t size, char *stack) = 0;
};

class heap_stack_allocator : public stack_allocator {
 public:
  char *allocate_stack(size_t size) override { return new char[size]; }
  void free_stack(size_t, char *stack) override { delete[] stack; }
};

class mmap_stack_allocator : public stack_allocator {
 public:
  char *allocate_stack(size_t size) override;
  void free_stack(size_t, char *stack) override;
};

}

#endif //PLS_INCLUDE_PLS_INTERNAL_BASE_STACK_ALLOCATOR_H_
