Commit c54b53da authored by Nils Philippsen's avatar Nils Philippsen

SGI: allocate memory more consistently

Allocate memory for both pixels and rows in the same way to make the
code easier understandable.
(cherry picked from commit b7ae59e9)
parent b428adfa
......@@ -311,7 +311,6 @@ load_image (const gchar *filename,
GimpDrawable *drawable; /* Drawable for layer */
GimpPixelRgn pixel_rgn; /* Pixel region for layer */
guchar **pixels, /* Pixel rows */
*pixel, /* Pixel data */
*pptr; /* Current pixel */
gushort **rows; /* SGI image data */
......@@ -421,11 +420,11 @@ load_image (const gchar *filename,
*/
tile_height = gimp_tile_height ();
pixel = g_new (guchar, ((gsize) tile_height) * sgip->xsize * bytes);
pixels = g_new (guchar *, tile_height);
pixels[0] = g_new (guchar, ((gsize) tile_height) * sgip->xsize * bytes);
for (i = 0; i < tile_height; i ++)
pixels[i] = pixel + sgip->xsize * bytes * i;
for (i = 1; i < tile_height; i ++)
pixels[i] = pixels[0] + sgip->xsize * bytes * i;
rows = g_new (unsigned short *, sgip->zsize);
rows[0] = g_new (unsigned short, ((gsize) sgip->xsize) * sgip->zsize);
......@@ -443,7 +442,7 @@ load_image (const gchar *filename,
{
if (count >= tile_height)
{
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel,
gimp_pixel_rgn_set_rect (&pixel_rgn, pixels[0],
0, y - count, drawable->width, count);
count = 0;
......@@ -481,7 +480,7 @@ load_image (const gchar *filename,
* Do the last n rows (count always > 0)
*/
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel, 0,
gimp_pixel_rgn_set_rect (&pixel_rgn, pixels[0], 0,
y - count, drawable->width, count);
/*
......@@ -490,7 +489,7 @@ load_image (const gchar *filename,
sgiClose (sgip);
g_free (pixel);
g_free (pixels[0]);
g_free (pixels);
g_free (rows[0]);
g_free (rows);
......@@ -526,7 +525,6 @@ save_image (const gchar *filename,
GimpDrawable *drawable; /* Drawable for layer */
GimpPixelRgn pixel_rgn; /* Pixel region for layer */
guchar **pixels, /* Pixel rows */
*pixel, /* Pixel data */
*pptr; /* Current pixel */
gushort **rows; /* SGI image data */
......@@ -581,11 +579,11 @@ save_image (const gchar *filename,
*/
tile_height = gimp_tile_height ();
pixel = g_new (guchar, ((gsize) tile_height) * drawable->width * zsize);
pixels = g_new (guchar *, tile_height);
pixels[0] = g_new (guchar, ((gsize) tile_height) * drawable->width * zsize);
for (i = 0; i < tile_height; i ++)
pixels[i]= pixel + drawable->width * zsize * i;
for (i = 1; i < tile_height; i ++)
pixels[i]= pixels[0] + drawable->width * zsize * i;
rows = g_new (gushort *, sgip->zsize);
rows[0] = g_new (gushort, ((gsize) sgip->xsize) * sgip->zsize);
......@@ -608,7 +606,7 @@ save_image (const gchar *filename,
else
count = tile_height;
gimp_pixel_rgn_get_rect (&pixel_rgn, pixel, 0, y, drawable->width, count);
gimp_pixel_rgn_get_rect (&pixel_rgn, pixels[0], 0, y, drawable->width, count);
/*
* Convert to shorts and write each color plane separately...
......@@ -633,7 +631,7 @@ save_image (const gchar *filename,
sgiClose (sgip);
g_free (pixel);
g_free (pixels[0]);
g_free (pixels);
g_free (rows[0]);
g_free (rows);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment