1
0
Fork 0

Refactor numtostr, use calloc instead of malloc.

This commit is contained in:
Wael Karram 2022-07-24 18:41:04 +03:00
parent d78a69c83f
commit fcea70353c
Signed by: wael
GPG Key ID: 3B356038CCB10808
1 changed files with 9 additions and 9 deletions

View File

@ -36,7 +36,7 @@ static inline char *stostr(short value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -67,7 +67,7 @@ static inline char *itostr(int value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -98,7 +98,7 @@ static inline char *uitostr(unsigned int value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -129,7 +129,7 @@ static inline char *dtostr(double value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -160,7 +160,7 @@ static inline char *ltostr(long value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -191,7 +191,7 @@ static inline char *ultostr(unsigned long value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -222,7 +222,7 @@ static inline char *lltostr(long long value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -253,7 +253,7 @@ static inline char *ulltostr(unsigned long long value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;
@ -284,7 +284,7 @@ static inline char *ftostr(float value) {
assert(length > 0);
/* Attempt to allocate the string. */
string = (char*) malloc((++length) * sizeof(char));
string = (char*) calloc(sizeof(char), (++length));
if (!string)
return NULL;