Skip to content

Commit 8f1e9c3

Browse files
authored
Implement basic free and add unit test for it (#25)
## Description Implement basic free and add unit test for it. ## Issues <!-- use if this PR fully resolves the issue --> Closes #23 <!-- use if this PR is linked but should not close the issue --> Related: #<issue-number> ## Testing free unit test
1 parent eff3cca commit 8f1e9c3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/free.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
namespace mem
44
{
55

6-
void free(void* ptr) { (void)ptr; }
6+
void free(void* ptr)
7+
{
8+
if (ptr == nullptr)
9+
{
10+
return;
11+
}
12+
}
713

814
} // namespace mem

tests/unit/test_free.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "malloc_from_scratch/memory_allocator.h"
2+
#include "test_utils.h"
3+
4+
int main()
5+
{
6+
mem::free(nullptr);
7+
8+
TEST_PASS();
9+
}

0 commit comments

Comments
 (0)