Skip to content

Commit d3e3e52

Browse files
committed
Fixed sign for size in string functions
1 parent cca6870 commit d3e3e52

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/string.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ void *memset(void *s, int c, size_t n)
1414

1515
char *strcat(char *dest, const char *src)
1616
{
17-
int i = 0;
18-
int j = strlen(dest);
17+
size_t i = 0;
18+
size_t j = strlen(dest);
1919

2020
for (i = 0; i < strlen(src); i++) {
2121
dest[j++] = src[i];
@@ -58,7 +58,7 @@ int strcasecmp(const char *s1, const char *s2)
5858
int strncasecmp(const char *s1, const char *s2, size_t n)
5959
{
6060
int diff = 0;
61-
int i = 0;
61+
size_t i = 0;
6262

6363
while (!diff && *s1) {
6464
diff = (int)*s1 - (int)*s2;
@@ -76,7 +76,7 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
7676

7777
size_t strlen(const char *s)
7878
{
79-
int i = 0;
79+
size_t i = 0;
8080

8181
while (s[i] != 0)
8282
i++;
@@ -86,8 +86,8 @@ size_t strlen(const char *s)
8686

8787
char *strncat(char *dest, const char *src, size_t n)
8888
{
89-
int i = 0;
90-
int j = strlen(dest);
89+
size_t i = 0;
90+
size_t j = strlen(dest);
9191

9292
for (i = 0; i < strlen(src); i++) {
9393
if (j >= (n - 1)) {
@@ -118,7 +118,7 @@ int strncmp(const char *s1, const char *s2, size_t n)
118118

119119
void *memcpy(void *dst, const void *src, size_t n)
120120
{
121-
int i;
121+
size_t i;
122122
const char *s = (const char *)src;
123123
char *d = (char *)dst;
124124

@@ -131,7 +131,7 @@ void *memcpy(void *dst, const void *src, size_t n)
131131

132132
char *strncpy(char *dst, const char *src, size_t n)
133133
{
134-
int i;
134+
size_t i;
135135

136136
for (i = 0; i < n; i++) {
137137
dst[i] = src[i];
@@ -144,7 +144,7 @@ char *strncpy(char *dst, const char *src, size_t n)
144144

145145
char *strcpy(char *dst, const char *src)
146146
{
147-
int i = 0;
147+
size_t i = 0;
148148

149149
while(1 < 2) {
150150
dst[i] = src[i];

0 commit comments

Comments
 (0)