chg: use calloc
This commit is contained in:
@@ -90,7 +90,7 @@ static int close_buffer(void *cookie)
|
||||
|
||||
FILE *open_memstream(char **bufptr, size_t *lenptr)
|
||||
{
|
||||
struct Buffer *b = (struct Buffer *)malloc(sizeof(struct Buffer));
|
||||
struct Buffer *b = (struct Buffer *)calloc(sizeof(struct Buffer), sizeof(uint8_t));
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
b->alloc = 0;
|
||||
|
||||
@@ -196,7 +196,7 @@ void SetFlushAfterWrite(bool value) {
|
||||
|
||||
int i,j;
|
||||
|
||||
int * output = (int* ) malloc(sizeof(int) * len);
|
||||
int * output = (int* ) calloc(sizeof(int) * len, sizeof(uint8_t));
|
||||
if ( !output ) return;
|
||||
|
||||
// clear mem
|
||||
|
||||
@@ -884,8 +884,8 @@ extern void strcreplace(char *buf, size_t len, char from, char to) {
|
||||
}
|
||||
|
||||
extern char *strmcopy(char *buf) {
|
||||
char* str = NULL;
|
||||
if ((str = (char*) malloc(strlen(buf) + 1)) != NULL) {
|
||||
char* str = (char*) calloc(strlen(buf) + 1, sizeof(uint8_t));
|
||||
if (str != NULL) {
|
||||
memset(str, 0, strlen(buf) + 1);
|
||||
strcpy(str, buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user