Commit b7ae59e9 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.
parent 4d9724f2
......@@ -310,7 +310,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 */
......@@ -420,11 +419,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);
......@@ -442,7 +441,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;
......@@ -480,7 +479,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);
/*
......@@ -489,7 +488,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);
......@@ -525,7 +524,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 */
......@@ -580,11 +578,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);
......@@ -607,7 +605,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...
......@@ -632,7 +630,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