PHP Code:
/***
* _ _
* (_) (_)
* __ ____ _ _ _____ ___ ___ ___ ___ _ __ ___
* \ \/ / _` | |/ _ \ \ / / |/ _ \ / __/ _ \| '_ ` _ \
* > < (_| | | (_) \ V /| | (_) | (_| (_) | | | | | |
* /_/\_\__, |_|\___/ \_/ |_|\___(_)___\___/|_| |_| |_|
* __/ |
* |___/
*/
#include <st***.h>
#include <stdlib.h>
///////////////////////////////// function xmalloc = malloc + NULL control
void * xmalloc (int byte){
void * punt;
punt = malloc (byte);
if (punt == NULL){
printf("Spazio non sufficiente\n");
exit(-1);
}
return punt;
}
//////////////////////////////////// function crea_matrice = malloc data and return pointer to data block begin address
float ** crea_matrice ( unsigned int righe, unsigned int colonne){
float * data;
float ** index;
int i;
data = (float *) xmalloc ( righe * colonne * sizeof(float));
index = (float **) xmalloc (righe * sizeof(float *));
for (i=0;i<righe;i++){
*(index + i) = data + ( i * colonne);
};
return index;
}