diff --git a/example2/example2.cpp b/example2/example2.cpp index 381ac4bd..910a9b4c 100644 --- a/example2/example2.cpp +++ b/example2/example2.cpp @@ -28,29 +28,11 @@ using namespace crnlib; -// Copied from crn_strutils.cpp without asserts. -char* example2_strcpy_safe(char* pDst, size_t dst_len, const char* pSrc) { - if (!dst_len) - return pDst; - - char* q = pDst; - char c; - - do { - if (dst_len == 1) { - *q++ = '\0'; - break; - } - - c = *pSrc++; - *q++ = c; - - dst_len--; - - } while (c); - - return pDst; -} +#if defined(_WIN32) +#define example2_strcpy_safe(d, l, s) strcpy_s(d, l, s) +#else +void example2_strcpy_safe(char *d, size_t l, const char* s) {l = strnlen(s, l - 1); memcpy(d, s, l); d[l] = '\0';} +#endif static int print_usage() { printf("Description: Transcodes .CRN to .DDS files using crn_decomp.h.\n");