diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-29 01:35:09 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-29 01:35:09 -0500 |
commit | 4595ada2f69b42670c85a63c7d2344af63f2afe7 (patch) | |
tree | 0d528d8177aceefcf74fb7306fc0fc7cc3c41ece /src/strings.c | |
parent | 8ae4f8f5985445b1ce3547975f407847c0fee0f7 (diff) | |
download | spmc-4595ada2f69b42670c85a63c7d2344af63f2afe7.tar.gz |
Minor fixes:
* size_t in place of int
* Moved some variables closer to their execution scope
* Add some error checks
Diffstat (limited to 'src/strings.c')
-rw-r--r-- | src/strings.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/strings.c b/src/strings.c index d6da7b6..782d66c 100644 --- a/src/strings.c +++ b/src/strings.c @@ -390,7 +390,7 @@ char **strdeldup(char **arr) { return NULL; } - int records; + size_t records; // Determine the length of the array for (records = 0; arr[records] != NULL; records++); @@ -453,7 +453,7 @@ char *strip(char *sptr) { *sptr = '\0'; return sptr; } - for (size_t i = len - 1; i >= 0; i--) { + for (size_t i = len - 1; ; i--) { if (isspace(sptr[i]) || isblank(sptr[i])) { sptr[i] = '\0'; } @@ -523,7 +523,7 @@ int isrelational(char ch) { */ void print_banner(const char *s, int len) { size_t s_len = strlen(s); - if (!s || !s_len) { + if (!s_len) { return; } for (int i = 0; i < (len / s_len); i++) { |