[gimp/gimp-2-6] SGI: allocate memory more consistently
- From: Nils Philippsen <nphilipp src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-6] SGI: allocate memory more consistently
- Date: Thu, 10 Dec 2009 12:07:40 +0000 (UTC)
commit c54b53da5589a0eadf5fd2c8d95bf9d01ad77d34
Author: Nils Philippsen <nils redhat com>
Date: Wed Dec 9 17:11:21 2009 +0100
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 b7ae59e9a470fa6e7cfdade1613729c94c3e3a5e)
plug-ins/file-sgi/sgi.c | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/plug-ins/file-sgi/sgi.c b/plug-ins/file-sgi/sgi.c
index 2c1be43..d062765 100644
--- a/plug-ins/file-sgi/sgi.c
+++ b/plug-ins/file-sgi/sgi.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]