Skip to content

Commit

Permalink
Replace function utest_strcpy with macro UTEST_STRCPY
Browse files Browse the repository at this point in the history
  • Loading branch information
facug91 committed Aug 15, 2023
1 parent 055cc59 commit eac7552
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions utest.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,11 @@ static UTEST_INLINE void *utest_realloc(void *const pointer, size_t new_size) {
return new_pointer;
}

static UTEST_INLINE void utest_strcpy(char * dest, size_t dest_size, const char * src) {
#if defined(_MSC_VER)
strcpy_s(dest, dest_size, src);
#define UTEST_STRCPY(dest, dest_size, src) strcpy_s(dest, dest_size, src)
#else
strcpy(dest, src);
#define UTEST_STRCPY(dest, dest_size, src) strcpy(dest, src)
#endif
}

static UTEST_INLINE utest_int64_t utest_ns(void) {
#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
Expand Down Expand Up @@ -907,7 +905,7 @@ utest_type_printer(long long unsigned int i) {
if (strcmp(e.what(), exception_message) != 0) { \
const size_t message_size = strlen(e.what()) + 1; \
message_caught = UTEST_PTR_CAST(char *, malloc(message_size)); \
utest_strcpy(message_caught, message_size, e.what()); \
UTEST_STRCPY(message_caught, message_size, e.what()); \
} \
} catch (...) { \
exception_caught = 2; \
Expand Down Expand Up @@ -1144,7 +1142,7 @@ utest_type_printer(long long unsigned int i) {
if (strcmp(e.what(), exception_message) != 0) { \
const size_t message_size = strlen(e.what()) + 1; \
message_caught = UTEST_PTR_CAST(char *, malloc(message_size)); \
utest_strcpy(message_caught, message_size, e.what()); \
UTEST_STRCPY(message_caught, message_size, e.what()); \
} \
} catch (...) { \
exception_caught = 2; \
Expand Down

0 comments on commit eac7552

Please sign in to comment.