Changed all malloc() to calloc()

This commit is contained in:
Thomas Schmitt 2010-07-12 19:32:41 +00:00
parent e2bdd521d8
commit 15266fb310
3 changed files with 13 additions and 13 deletions

View File

@ -34,7 +34,7 @@
/* Macro for creation of arrays of objects (or single objects) */ /* Macro for creation of arrays of objects (or single objects) */
#define TSOB_FELD(typ,anz) (typ *) malloc((anz)*sizeof(typ)); #define TSOB_FELD(typ,anz) (typ *) calloc(anz, sizeof(typ));
#define Cdrfifo_buffer_chunK 2048 #define Cdrfifo_buffer_chunK 2048

View File

@ -420,7 +420,7 @@ static int Cdrskin_abort_leveL= 0;
/* Imported from scdbackup-0.8.5/src/cd_backup_planer.c */ /* Imported from scdbackup-0.8.5/src/cd_backup_planer.c */
/** Macro for creation of arrays of objects (or single objects) */ /** Macro for creation of arrays of objects (or single objects) */
#define TSOB_FELD(typ,anz) (typ *) malloc((anz)*sizeof(typ)); #define TSOB_FELD(typ,anz) (typ *) calloc(anz, sizeof(typ));
/** Convert a text so that eventual characters special to the shell are /** Convert a text so that eventual characters special to the shell are
@ -570,7 +570,7 @@ int Sfile_multi_read_argv(char *progname, char **filenames, int filename_count,
if(pass==0) if(pass==0)
maxl= strlen(progname)+1; maxl= strlen(progname)+1;
else { else {
(*argv)[0]= (char *) malloc(strlen(progname)+1); (*argv)[0]= (char *) calloc(1, strlen(progname)+1);
if((*argv)[0]==NULL) if((*argv)[0]==NULL)
{ret= -1; goto ex;} {ret= -1; goto ex;}
strcpy((*argv)[0],progname); strcpy((*argv)[0],progname);
@ -601,7 +601,7 @@ int Sfile_multi_read_argv(char *progname, char **filenames, int filename_count,
} else { } else {
if(argcount >= *argc) if(argcount >= *argc)
break; break;
(*argv)[argcount]= (char *) malloc(l+1); (*argv)[argcount]= (char *) calloc(1, l+1);
if((*argv)[argcount]==NULL) if((*argv)[argcount]==NULL)
{ret= -1; goto ex;} {ret= -1; goto ex;}
strcpy((*argv)[argcount],buf); strcpy((*argv)[argcount],buf);
@ -615,9 +615,9 @@ int Sfile_multi_read_argv(char *progname, char **filenames, int filename_count,
if(pass==0){ if(pass==0){
*argc= argcount; *argc= argcount;
if(argcount>0) { if(argcount>0) {
*argv= (char **) malloc(argcount*sizeof(char *)); *argv= (char **) calloc(argcount, sizeof(char *));
*argidx= (int *) malloc(argcount*sizeof(int)); *argidx= (int *) calloc(argcount, sizeof(int));
*arglno= (int *) malloc(argcount*sizeof(int)); *arglno= (int *) calloc(argcount, sizeof(int));
if(*argv==NULL || *argidx==NULL || *arglno==NULL) if(*argv==NULL || *argidx==NULL || *arglno==NULL)
{ret= -1; goto ex;} {ret= -1; goto ex;}
} }
@ -817,8 +817,8 @@ int Cdradrtrn_add(struct CdradrtrN *trn, char *from, char *to, int flag)
} }
if(strlen(from)>=Cdrskin_adrleN || strlen(to)>=Cdrskin_adrleN) if(strlen(from)>=Cdrskin_adrleN || strlen(to)>=Cdrskin_adrleN)
return(0); return(0);
trn->from_address[cnt]= malloc(strlen(from_pt)+1); trn->from_address[cnt]= calloc(1, strlen(from_pt)+1);
trn->to_address[cnt]= malloc(strlen(to_pt)+1); trn->to_address[cnt]= calloc(1, strlen(to_pt)+1);
if(trn->from_address[cnt]==NULL || if(trn->from_address[cnt]==NULL ||
trn->to_address[cnt]==NULL) trn->to_address[cnt]==NULL)
return(-2); return(-2);
@ -4741,8 +4741,8 @@ int Cdrskin_scanbus(struct CdrskiN *skin, int flag)
int *drives_busses= NULL; int *drives_busses= NULL;
struct stat stbuf; struct stat stbuf;
drives_shown= malloc(skin->n_drives+1); drives_shown= calloc(1, skin->n_drives+1);
drives_busses= malloc((skin->n_drives+1) * sizeof(int)); drives_busses= calloc((skin->n_drives+1), sizeof(int));
if(drives_shown == NULL || drives_busses == NULL) if(drives_shown == NULL || drives_busses == NULL)
{ret= -1; goto ex;} {ret= -1; goto ex;}
for(i=0;i<skin->n_drives;i++) for(i=0;i<skin->n_drives;i++)
@ -6897,7 +6897,7 @@ int Cdrskin_direct_write(struct CdrskiN *skin, int flag)
if(ret<=0) if(ret<=0)
goto ex; goto ex;
} }
buf= malloc(max_chunksize); buf= calloc(1, max_chunksize);
if(buf==NULL) { if(buf==NULL) {
fprintf(stderr, fprintf(stderr,
"cdrskin: FATAL : Cannot allocate %d bytes of read buffer.\n", "cdrskin: FATAL : Cannot allocate %d bytes of read buffer.\n",

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2010.07.06.113356" #define Cdrskin_timestamP "2010.07.12.193201"