Skip to content

Commit 73ce0cb

Browse files
authored
Merge pull request #2 from icgmilk/JimHsu
Refactor function 'snprintf(size_t n)' to replace 'size_t' with 'int'
2 parents 4db8d7e + 0db0e9c commit 73ce0cb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: lib/c.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,13 @@ void free(void *ptr)
725725
__freelist_head = cur;
726726
}
727727

728-
void snprintf(char *buffer, size_t n, char *str, ...)
728+
void snprintf(char *buffer, int n, char *str, ...)
729729
{
730730
int *var_args = &str + 4;
731731
int si = 0, bi = 0, pi = 0;
732732

733733
while (str[si]) {
734-
if (bi >= n-1) {
734+
if (bi >= n - 1) {
735735
break;
736736
} else if (str[si] != '%') {
737737
buffer[bi] = str[si];
@@ -787,5 +787,6 @@ void snprintf(char *buffer, size_t n, char *str, ...)
787787
si++;
788788
}
789789
}
790-
if (bi < n) buffer[bi] = '\0';
790+
if (bi < n)
791+
buffer[bi] = '\0';
791792
}

0 commit comments

Comments
 (0)