ext/RMagick/rmimage.c in rmagick-1.15.14 vs ext/RMagick/rmimage.c in rmagick-1.15.15
- old
+ new
@@ -1,6 +1,6 @@
-/* $Id: rmimage.c,v 1.192.2.5.2.6 2008/05/05 22:59:40 rmagick Exp $ */
+/* $Id: rmimage.c,v 1.192.2.5.2.7 2008/09/10 23:22:46 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2008 by Timothy P. Hunter
| Name: rmimage.c
| Author: Tim Hunter
| Purpose: Image class method definitions for RMagick
@@ -3076,13 +3076,13 @@
long x, npixels;
char *map;
long map_l;
union
{
- volatile float *f;
- volatile Quantum *i;
- volatile void *v;
+ float *f;
+ Quantum *i;
+ void *v;
} pixels;
int type;
StorageType stg_type;
class = class; // Suppress "never referenced" message from icc
@@ -3111,16 +3111,16 @@
// Inspect the first element in the pixels array to determine the expected
// type of all the elements. Allocate the pixel buffer.
pixel0 = rb_ary_entry(pixels_arg, 0);
if (TYPE(pixel0) == T_FLOAT)
{
- pixels.f = ALLOC_N(volatile float, npixels);
+ pixels.f = ALLOC_N(float, npixels);
stg_type = FloatPixel;
}
else if (TYPE(pixel0) == T_FIXNUM)
{
- pixels.i = ALLOC_N(volatile Quantum, npixels);
+ pixels.i = ALLOC_N(Quantum, npixels);
stg_type = FIX_STG_TYPE;
}
else
{
rb_raise(rb_eTypeError, "element 0 in pixel array is %s, must be Fixnum or Double"
@@ -3165,21 +3165,21 @@
rb_raise(rb_eNoMemError, "not enough memory to continue.");
}
SetImageExtent(image, width, height);
(void) SetImageBackgroundColor(image);
- (void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, (void *)pixels.v);
+ (void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, pixels.v);
rm_check_image_exception(image, DestroyOnError);
#else
- image = ConstituteImage(width, height, map, stg_type, (void *)pixels.v, &exception);
+ image = ConstituteImage(width, height, map, stg_type, pixels.v, &exception);
rm_check_exception(&exception, image, DestroyOnError);
#endif
(void) DestroyExceptionInfo(&exception);
DestroyConstitute();
- xfree((void *)pixels.v);
+ xfree(pixels.v);
return rm_image_new(image);
}
/*
@@ -3344,11 +3344,11 @@
}
GetExceptionInfo(&exception);
new_image = ConvolveImage(image, order, (double *)kernel, &exception);
- xfree((double *)kernel);
+ xfree((void *)kernel);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
@@ -3403,11 +3403,11 @@
}
GetExceptionInfo(&exception);
new_image = ConvolveImageChannel(image, channels, order, (double *)kernel, &exception);
- xfree((double *)kernel);
+ xfree((void *)kernel);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
@@ -3751,13 +3751,13 @@
long mapL;
MagickBooleanType okay;
ExceptionInfo exception;
union
{
- volatile Quantum *i;
- volatile double *f;
- volatile void *v;
+ Quantum *i;
+ double *f;
+ void *v;
} pixels;
if (argc < 5 || argc > 6)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 5 or 6)", argc);
@@ -3788,11 +3788,11 @@
#if defined(HAVE_EXPORTIMAGEPIXELS)
ExportImagePixels
#else
DispatchImage
#endif
- (image, x, y, columns, rows, map, stg_type, (void *)pixels.v, &exception);
+ (image, x, y, columns, rows, map, stg_type, pixels.v, &exception);
if (!okay)
{
goto exit;
}
@@ -3816,11 +3816,11 @@
(void) rb_ary_push(pixels_ary, rb_float_new((double)pixels.f[n]));
}
}
exit:
- xfree((void *)pixels.v);
+ xfree(pixels.v);
return pixels_ary;
}
/*
Method: Image#display
@@ -4413,11 +4413,11 @@
GetExceptionInfo(&exception);
okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, &exception);
if (!okay)
{
- xfree((unsigned int *)pixels);
+ xfree((void *)pixels);
CHECK_EXCEPTION()
// Should never get here...
rm_magick_error("ExportImagePixels failed with no explanation.", NULL);
}
@@ -4428,11 +4428,11 @@
for (n = 0; n < npixels; n++)
{
(void) rb_ary_push(ary, UINT2NUM((unsigned int)pixels[n]));
}
- xfree((unsigned int *)pixels);
+ xfree((Quantum *)pixels);
return ary;
#else
rm_not_implemented();
@@ -4906,10 +4906,11 @@
volatile VALUE info_obj;
ExceptionInfo exception;
void *blob;
long length;
+ class = class; // defeat gcc message
blob = (void *) STRING_PTR_LEN(blob_arg, length);
// Get a new Info object - run the parm block if supplied
info_obj = rm_info_new();
Data_Get_Struct(info_obj, Info, info);
@@ -5150,11 +5151,11 @@
VALUE y_arg,
VALUE cols_arg,
VALUE rows_arg)
{
Image *image;
- PixelPacket *pixels;
+ const PixelPacket *pixels;
ExceptionInfo exception;
long x, y;
unsigned long columns, rows;
long size, n;
VALUE pixel_ary;
@@ -5163,20 +5164,20 @@
x = NUM2LONG(x_arg);
y = NUM2LONG(y_arg);
columns = NUM2ULONG(cols_arg);
rows = NUM2ULONG(rows_arg);
- if ((x+columns) > image->columns || (y+rows) > image->rows || columns < 0 || rows < 0)
+ if ((x+columns) > image->columns || (y+rows) > image->rows)
{
rb_raise(rb_eRangeError, "geometry (%lux%lu%+ld%+ld) exceeds image bounds"
, columns, rows, x, y);
}
// Cast AcquireImagePixels to get rid of the const qualifier. We're not going
// to change the pixels but I don't want to make "pixels" const.
GetExceptionInfo(&exception);
- pixels = (PixelPacket *)AcquireImagePixels(image, x, y, columns, rows, &exception);
+ pixels = AcquireImagePixels(image, x, y, columns, rows, &exception);
CHECK_EXCEPTION()
(void) DestroyExceptionInfo(&exception);
// If the function failed, return a 0-length array.
@@ -5620,11 +5621,11 @@
{
x += sprintf(buffer+x, " %lub", (unsigned long) GetBlobSize(image));
}
}
- assert(x < sizeof(buffer)-1);
+ assert(x < ((int)sizeof(buffer)-1));
buffer[x] = '\0';
return rb_str_new2(buffer);
}
@@ -5865,11 +5866,11 @@
info = CloneImageInfo(NULL);
blob = STRING_PTR_LEN(str, length);
// Must be as least as big as the 1st 4 fields in DumpedImage
- if (length <= sizeof(DumpedImage)-MaxTextExtent)
+ if (length <= (long)sizeof(DumpedImage)-MaxTextExtent)
{
rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)");
}
// Retrieve & validate the image format from the header portion
@@ -5891,10 +5892,10 @@
}
mi.len = ((DumpedImage *)blob)->len;
// Must be bigger than the header
- if (length <= mi.len+sizeof(DumpedImage)-MaxTextExtent)
+ if (length <= mi.len+((long)sizeof(DumpedImage))-MaxTextExtent)
{
rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)");
}
memcpy(info->magick, ((DumpedImage *)blob)->magick, mi.len);