Skip to content

Commit

Permalink
example3: make strncpy multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jun 28, 2024
1 parent 13259c5 commit 3991607
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example3/example3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ int main(int argc, char* argv[]) {
if (++i >= argc)
return error("Expected output filename!");

#if defined(_WIN32)
strcpy_s(out_filename, sizeof(out_filename), argv[i]);
#else
strncpy(out_filename, argv[i], sizeof(out_filename));
#endif
} else if (!crnlib_stricmp(argv[i], "-nonsrgb"))
srgb_colorspace = false;
else if (!crnlib_stricmp(argv[i], "-pixelformat")) {
Expand Down Expand Up @@ -224,7 +228,11 @@ int main(int argc, char* argv[]) {
char dst_filename[FILENAME_MAX];
crnlib_snprintf(dst_filename, sizeof(dst_filename), "%s%s%s.dds", drive_buf, dir_buf, fname_buf);
if (out_filename[0])
strcpy(dst_filename, out_filename);
#if defined(_WIN32)
strcpy_s(dst_filename, sizeof(dst_filename), out_filename);
#else
strncpy(dst_filename, out_filename, sizeof(dst_filename));
#endif

printf("Writing DDS file: %s\n", dst_filename);

Expand Down

0 comments on commit 3991607

Please sign in to comment.