diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-11-14 11:32:34 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-11-14 23:56:16 -0500 |
commit | f6c719d7ec71cc7771c46d3daa390924a3871ba3 (patch) | |
tree | e6209f23565db01809f75067247e667963092ff6 /firmware/include | |
parent | b25a9d8f99b75570d18ea64602de7fe48da612d6 (diff) | |
download | rockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.tar.gz rockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.zip |
replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation
in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base
Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/string-extra.h | 1 | ||||
-rw-r--r-- | firmware/include/strmemccpy.h | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/firmware/include/string-extra.h b/firmware/include/string-extra.h index 549a018dfc..a9b34661a7 100644 --- a/firmware/include/string-extra.h +++ b/firmware/include/string-extra.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "strlcat.h" | 25 | #include "strlcat.h" |
26 | #include "strcasecmp.h" | 26 | #include "strcasecmp.h" |
27 | #include "strcasestr.h" | 27 | #include "strcasestr.h" |
28 | #include "strmemccpy.h" | ||
28 | #include "strtok_r.h" | 29 | #include "strtok_r.h" |
29 | #include "memset16.h" | 30 | #include "memset16.h" |
30 | 31 | ||
diff --git a/firmware/include/strmemccpy.h b/firmware/include/strmemccpy.h new file mode 100644 index 0000000000..c7004610dd --- /dev/null +++ b/firmware/include/strmemccpy.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2022 William Wilgus | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #ifndef __STRMEMCCPY_H__ | ||
24 | #define __STRMEMCCPY_H__ | ||
25 | /* copies src to a buffer of len bytes stopping after | ||
26 | * len or the first NULL (\0) in src | ||
27 | * NULL terminates except when len = 0 | ||
28 | * If len was exceeded NULL is returned otherwise returns | ||
29 | * a pointer to the first byte following the NULL in dst. | ||
30 | */ | ||
31 | char * strmemccpy(char *dst, const char *src, size_t len); | ||
32 | #endif | ||