Skip to content

Commit

Permalink
ACE: remove FREE_AND_NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
KuhakuPixel committed Aug 8, 2023
1 parent 9548c1c commit ba8f209
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
13 changes: 0 additions & 13 deletions ACE/engine/include/ACE/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@
*PTR_TO_DOUBLE = ((double)(end - begin) / CLOCKS_PER_SEC); \
} while (0)

/*
* free [ptr] and assign NULL
*
* macro is used since cpp compiler doesn't allow passing
* different type of pointer to `void*`
* */

#define FREE_AND_NULL(ptr) \
do { \
free(ptr); \
ptr = NULL; \
} while (0)

/*
* instantiate a template for all numeric types
* this is useful when template functions/classes implementation
Expand Down
22 changes: 0 additions & 22 deletions ACE/engine/test/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,3 @@ TEST_CASE("TIME_ACTION", "[COMMON]") {
}
printf("sum: %d\n", sum);
}
TEST_CASE("free_and_null", "[COMMON]") {

{
size_t *arr = (size_t *)malloc(sizeof(size_t) * 10000);
REQUIRE(arr != NULL);
FREE_AND_NULL(arr);
REQUIRE(arr == NULL);
}

{
size_t *arr = (size_t *)malloc(sizeof(size_t) * 1000000);
REQUIRE(arr != NULL);
FREE_AND_NULL(arr);
REQUIRE(arr == NULL);
}

{
size_t *null_ptr = NULL;
FREE_AND_NULL(null_ptr);
REQUIRE(null_ptr == NULL);
}
}

0 comments on commit ba8f209

Please sign in to comment.