summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-08-28 15:35:48 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-08-28 15:35:48 -0400
commit38e5501205573597c6b8ef92e56ca76141b8e792 (patch)
tree1ade260689696b812e45ad5d2e43a4b7a71cff38 /util
parent1661532486d742462f834d2e57f1ad827d6e8916 (diff)
Improved types (now gives error when you annotate the wrong type)
Diffstat (limited to 'util')
-rw-r--r--util/str.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/str.c b/util/str.c
index b05cc63..ac4fb26 100644
--- a/util/str.c
+++ b/util/str.c
@@ -6,13 +6,18 @@ destsz must be greater than 0.
*/
size_t str_copy(char *dest, size_t destsz, const char *src) {
assert(destsz);
+ if (!*src) {
+ *dest = 0;
+ return 0;
+ }
for (size_t i = 0; i < destsz-1; i++) {
+ *dest = *src;
if (!*src) {
*dest = 0;
return i;
}
- *dest++ = *src++;
+ src++; dest++;
}
- dest[destsz] = 0;
+ dest[destsz-1] = 0;
return destsz-1;
}