Skip to content

Commit

Permalink
Support initialization of allocated memory
Browse files Browse the repository at this point in the history
  • Loading branch information
janweinstock committed Feb 29, 2024
1 parent 83f3290 commit 473092f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/mwr/utils/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class memory
virtual ~memory();

void alloc(size_t size);
void alloc(size_t size, int fill);
void alloc0(size_t size);
void free();

memory(const memory&) = delete;
Expand All @@ -57,6 +59,15 @@ inline u8& memory::operator[](size_t idx) {
return m_data[idx];
}

inline void memory::alloc(size_t size, int fill) {
alloc(size);
memset(m_data, (int)fill, m_size);
}

inline void memory::alloc0(size_t size) {
alloc(size, 0);
}

} // namespace mwr

#endif

0 comments on commit 473092f

Please sign in to comment.