diff --git a/src/free.cpp b/src/free.cpp index b4f0a6a..da29fd2 100644 --- a/src/free.cpp +++ b/src/free.cpp @@ -3,6 +3,12 @@ namespace mem { -void free(void* ptr) { (void)ptr; } +void free(void* ptr) +{ + if (ptr == nullptr) + { + return; + } +} } // namespace mem diff --git a/tests/unit/test_free.cpp b/tests/unit/test_free.cpp new file mode 100644 index 0000000..a58b158 --- /dev/null +++ b/tests/unit/test_free.cpp @@ -0,0 +1,9 @@ +#include "malloc_from_scratch/memory_allocator.h" +#include "test_utils.h" + +int main() +{ + mem::free(nullptr); + + TEST_PASS(); +}