From d0d6b4e211926ebed00db501fcbd5d751f36e23c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Mon, 15 Jul 2024 01:29:02 +0200 Subject: [PATCH] other way --- example2/example2.cpp | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) 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");