1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int amallocd2(double **d2,unsigned int size1,unsigned int size2){
unsigned int i,j;
if( (d2 =(double **)malloc(sizeof(double*)*size1)) == NULL){
fprintf(stderr,"%s, in file: %s Func: %s Line: %d\n",
_MSG_ALLOC,__FILE__, __FUNCTION__,__LINE__);
}
for(i =0; i<size1; i++){
if( (d2[i]=(double*)malloc(sizeof(double)*size2)) == NULL){
fprintf(stderr,"%s, in file: %s Func: %s Line: %d\n",
_MSG_ALLOC,__FILE__, __FUNCTION__,__LINE__);
for(j=i-1; j>0; j--){
free( d2[j]);
}
free(d2);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
} |
Partager