diff --git a/pipi/codec/oric.c b/pipi/codec/oric.c index 28c4be4..d31d6ca 100644 --- a/pipi/codec/oric.c +++ b/pipi/codec/oric.c @@ -50,14 +50,18 @@ pipi_image_t *pipi_load_oric(char const *name) 0xff, 0xff, 0xff, 0xff, }; - uint8_t screen[WIDTH * HEIGHT / 6]; pipi_image_t *img; pipi_pixels_t *p; - uint8_t *data; + uint8_t *screen, *data; int x, y, i; + screen = malloc(WIDTH * HEIGHT / 6); + if(read_screen(name, screen) < 0) + { + free(screen); return NULL; + } img = pipi_new(WIDTH, HEIGHT); p = pipi_getpixels(img, PIPI_PIXELS_RGBA_C); @@ -99,6 +103,8 @@ pipi_image_t *pipi_load_oric(char const *name) } } + free(screen); + img->codec_priv = NULL; img->wrap = 0; @@ -109,10 +115,10 @@ pipi_image_t *pipi_load_oric(char const *name) int pipi_save_oric(pipi_image_t *img, char const *name) { - uint8_t screen[WIDTH * HEIGHT / 6]; pipi_image_t *tmp = NULL; pipi_pixels_t *p; float *data; + uint8_t *screen; FILE *fp; size_t len; @@ -140,13 +146,19 @@ int pipi_save_oric(pipi_image_t *img, char const *name) else p = pipi_getpixels(img, PIPI_PIXELS_RGBA_F); data = p->pixels; + screen = malloc(WIDTH * HEIGHT / 6); write_screen(data, screen); if(tmp) + { + free(screen); pipi_free(tmp); + } fwrite(screen, 1, WIDTH * HEIGHT / 6, fp); fclose(fp); + free(screen); + return 0; }