summaryrefslogtreecommitdiffstats
path: root/omni/memory.h
blob: def1cc0726a10becd4ef720fa609ba8bec8caa71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef OMNI_MEMORY_H
#define OMNI_MEMORY_H

#include "stdint.h"

struct Layout {
  usize size;
  usize align;

  template <typename T>
  constexpr static Layout of(usize n) noexcept {
    return Layout{n * sizeof(T), alignof(T)};
  }

  static bool from(usize size, usize align) noexcept {
    return Layout{size, align};
  }
};

struct Allocator {
  virtual u8* allocate(Layout layout) noexcept;
  virtual void deallocate(u8* ptr);
};

#endif