-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The POSIX/C23 function `memccpy()` provides benefits that combat downfalls of other C-provided copying functions, e.g., `strcpy()` and `strcat()` * One of these downfalls is the quadratic runtime when trying to concatenate two strings using `strcat()` - New macro within `SW_Defines.h` * As previously mentioned, the `memccpy()` function is a POSIX standard or contained within C23 * The program now checks to see these conditions are met, and if they are we set the macro `sw_memccpy()` to `memccpy()` * Otherwise, if neither of these conditions are provided, we use the new custom SOILWAT2 function - `sw_memccpy_custom()` - This function provides the same functionality (see article link below) - This function also makes use of the compiler macro '__restrict' which is supported by Clang and GCC * It is not a C++ standard to have a 'restrict' keyword - Replaced all instances of `strcpy()` with `sw_memccpy()` (other than the instance in `Str_Dup()` - Replaced all instances of `strcat()` with `sw_memccpy()` - Replaced simple instances of `snprintf()` with `sw_memccpy()` * A simple instance refers to the use of `snprintf()` to write a single string that is not formatted (e.g., snprintf(..., ..., "%s", ...)) or similar - `MkDir()` gains new possible warning message * This occurs when the buffer fills and the directory is created, but by another name than what was expectedc ** For more information see https://developers.redhat.com/blog/2019/08/12/efficient-string-copying-and-concatenation-in-c#choosing_a_solution
- Loading branch information
1 parent
fa7d059
commit e0557d1
Showing
14 changed files
with
516 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.