Announcement

Collapse
No announcement yet.

Matrice Dinamica - NO Realloc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matrice Dinamica - NO Realloc

    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 righeunsigned 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 + ( colonne);
                
            };
            
            return 
    index;
        

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia