Ignore:
Timestamp:
Oct 13, 2008 3:15:06 AM (6 years ago)
Author:
sam
Message:

libpipi: replace large stack buffer allocations with malloc().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/codec/oric.c

    r2902 r2941  
    5151    }; 
    5252 
    53     uint8_t screen[WIDTH * HEIGHT / 6]; 
    5453    pipi_image_t *img; 
    5554    pipi_pixels_t *p; 
    56     uint8_t *data; 
     55    uint8_t *screen, *data; 
    5756    int x, y, i; 
    5857 
     58    screen = malloc(WIDTH * HEIGHT / 6); 
     59 
    5960    if(read_screen(name, screen) < 0) 
     61    { 
     62        free(screen); 
    6063        return NULL; 
     64    } 
    6165 
    6266    img = pipi_new(WIDTH, HEIGHT); 
     
    100104    } 
    101105 
     106    free(screen); 
     107 
    102108    img->codec_priv = NULL; 
    103109 
     
    110116int pipi_save_oric(pipi_image_t *img, char const *name) 
    111117{ 
    112     uint8_t screen[WIDTH * HEIGHT / 6]; 
    113118    pipi_image_t *tmp = NULL; 
    114119    pipi_pixels_t *p; 
    115120    float *data; 
     121    uint8_t *screen; 
    116122    FILE *fp; 
    117123    size_t len; 
     
    141147        p = pipi_getpixels(img, PIPI_PIXELS_RGBA_F); 
    142148    data = p->pixels; 
     149    screen = malloc(WIDTH * HEIGHT / 6); 
    143150    write_screen(data, screen); 
    144151    if(tmp) 
     152    { 
     153        free(screen); 
    145154        pipi_free(tmp); 
     155    } 
    146156 
    147157    fwrite(screen, 1, WIDTH * HEIGHT / 6, fp); 
    148158    fclose(fp); 
     159 
     160    free(screen); 
    149161 
    150162    return 0; 
Note: See TracChangeset for help on using the changeset viewer.