ext/RMagick/rmutil.c in rmagick-2.3.0 vs ext/RMagick/rmutil.c in rmagick-2.4.0

- old
+ new

@@ -1,6 +1,6 @@ -/* $Id: rmutil.c,v 1.153 2008/03/29 15:19:15 rmagick Exp $ */ +/* $Id: rmutil.c,v 1.155 2008/05/21 22:32:41 rmagick Exp $ */ /*============================================================================\ | Copyright (C) 2008 by Timothy P. Hunter | Name: rmutil.c | Author: Tim Hunter | Purpose: Utility functions for RMagick @@ -14,11 +14,11 @@ static const char *StretchType_name(StretchType); static void Color_Name_to_PixelPacket(PixelPacket *, VALUE); static VALUE Enum_type_values(VALUE); static VALUE Enum_type_inspect(VALUE); static void handle_exception(ExceptionInfo *, Image *, ErrorRetention); -static VALUE Pixel_from_MagickPixelPacket(MagickPixelPacket *); +static VALUE Pixel_from_MagickPixelPacket(const MagickPixelPacket *); #define ENUMERATORS_CLASS_VAR "@@enumerators" /* Extern: magick_safe_malloc, magick_malloc, magick_free, magick_realloc @@ -575,17 +575,17 @@ Static: rm_set_magick_pixel_packet Purpose: Convert a PixelPacket to a MagickPixelPacket Notes: Same code as the private function SetMagickPixelPacket in ImageMagick. */ -static void rm_set_magick_pixel_packet(Pixel *pixel, IndexPacket *index, MagickPixelPacket *pp) +static void rm_set_magick_pixel_packet(Pixel *pixel, IndexPacket *index_packet, MagickPixelPacket *pp) { pp->red = (MagickRealType) pixel->red; pp->green = (MagickRealType) pixel->green; pp->blue = (MagickRealType) pixel->blue; pp->opacity = (MagickRealType) (pp->matte ? pixel->opacity : OpaqueOpacity); - pp->index = (MagickRealType) ((pp->colorspace == CMYKColorspace) && (index ? *index : 0)); + pp->index = (MagickRealType) ((pp->colorspace == CMYKColorspace) && (index_packet ? *index_packet : 0)); } /* @@ -1739,11 +1739,11 @@ /* Static: ImageType_name Purpose: Return the name of a ImageType enum as a string */ -static char * +static const char * ImageType_name(ImageType type) { switch(type) { ENUM_TO_NAME(UndefinedType) @@ -2024,11 +2024,11 @@ name = rb_str_new2(ci->name); compliance_type = ci->compliance; compliance = ComplianceType_new(compliance_type); - color = Pixel_from_MagickPixelPacket((MagickPixelPacket *)(&(ci->color))); + color = Pixel_from_MagickPixelPacket(&(ci->color)); return rb_funcall(Class_Color, rm_ID_new, 3 , name, compliance, color); } @@ -2119,11 +2119,11 @@ Extern: Pixel_from_PixelPacket Purpose: Create a Magick::Pixel object from a PixelPacket structure. Notes: bypasses normal Pixel.new, Pixel#initialize methods */ VALUE -Pixel_from_PixelPacket(PixelPacket *pp) +Pixel_from_PixelPacket(const PixelPacket *pp) { Pixel *pixel; pixel = ALLOC(Pixel); *pixel = *pp; @@ -2135,11 +2135,11 @@ Static: Pixel_from_MagickPixelPacket Purpose: Create a Magick::Pixel object from a MagickPixelPacket structure. Notes: bypasses normal Pixel.new, Pixel#initialize methods */ static VALUE -Pixel_from_MagickPixelPacket(MagickPixelPacket *pp) +Pixel_from_MagickPixelPacket(const MagickPixelPacket *pp) { Pixel *pixel; pixel = ALLOC(Pixel); pixel->red = ROUND_TO_QUANTUM(pp->red); @@ -2202,14 +2202,14 @@ // image can be NULL GetMagickPixelPacket(image, mpp); memset(&pp, '\0', sizeof(pp)); Color_to_PixelPacket(&pp, color); - mpp->red = pp.red; - mpp->green = pp.green; - mpp->blue = pp.blue; - mpp->opacity = pp.opacity; + mpp->red = (MagickRealType) pp.red; + mpp->green = (MagickRealType) pp.green; + mpp->blue = (MagickRealType) pp.blue; + mpp->opacity = (MagickRealType) pp.opacity; } /* Extern: PrimaryInfo_from_PrimaryInfo(pp) @@ -2473,11 +2473,11 @@ /* External: Font_from_TypeInfo Purpose: Convert a TypeInfo structure to a Magick::Font */ VALUE -Font_from_TypeInfo(TypeInfo *ti) +Font_from_TypeInfo(const TypeInfo *ti) { volatile VALUE name, description, family; volatile VALUE style, stretch, weight; volatile VALUE encoding, foundry, format; @@ -2752,11 +2752,11 @@ /* * Extern: rm_define_enum_type * Purpose: set up a subclass of Enum */ -VALUE rm_define_enum_type(char *tag) +VALUE rm_define_enum_type(const char *tag) { VALUE class; class = rb_define_class_under(Module_Magick, tag, Class_Enum);\ @@ -2890,16 +2890,16 @@ * Method: xxx#initialize * Purpose: initialize method for all Enum subclasses */ VALUE Enum_type_initialize(VALUE self, VALUE sym, VALUE val) { - volatile VALUE super_argv[2]; + VALUE super_argv[2]; volatile VALUE enumerators; super_argv[0] = sym; super_argv[1] = val; - (void) rb_call_super(2, (VALUE *)super_argv); + (void) rb_call_super(2, (const VALUE *)super_argv); if (rb_cvar_defined(CLASS_OF(self), rb_intern(ENUMERATORS_CLASS_VAR)) != Qtrue) { rb_cv_set(CLASS_OF(self), ENUMERATORS_CLASS_VAR, rb_ary_new()); } @@ -3076,15 +3076,15 @@ /* External: write_temp_image Purpose: Write a temporary copy of the image to the IM registry Returns: the "filename" of the registered image - Notes: The `tmpnam' argument must point to an char array + Notes: The `temp_name' argument must point to an char array of size MaxTextExtent. */ void -rm_write_temp_image(Image *image, char *tmpnam) +rm_write_temp_image(Image *image, char *temp_name) { #if defined(HAVE_SETIMAGEREGISTRY) #define TMPNAM_CLASS_VAR "@@_tmpnam_" @@ -3108,14 +3108,14 @@ rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id)); } id += 1; rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id)); - sprintf(tmpnam, "mpri:%d", id); + sprintf(temp_name, "mpri:%d", id); // Omit "mpri:" from filename to form the key - okay = SetImageRegistry(ImageRegistryType, tmpnam+5, image, &exception); + okay = SetImageRegistry(ImageRegistryType, temp_name+5, image, &exception); CHECK_EXCEPTION() DestroyExceptionInfo(&exception); if (!okay) { rb_raise(rb_eRuntimeError, "SetImageRegistry failed."); @@ -3134,11 +3134,11 @@ if (registry_id < 0) { rb_raise(rb_eRuntimeError, "SetMagickRegistry failed."); } - sprintf(tmpnam, "mpri:%ld", registry_id); + sprintf(temp_name, "mpri:%ld", registry_id); #endif } /* @@ -3146,23 +3146,23 @@ Purpose: Delete the temporary image from the registry Returns: void */ void -rm_delete_temp_image(char *tmpnam) +rm_delete_temp_image(char *temp_name) { #if defined(HAVE_SETIMAGEREGISTRY) - MagickBooleanType okay = DeleteImageRegistry(tmpnam+5); + MagickBooleanType okay = DeleteImageRegistry(temp_name+5); if (!okay) { - rb_warn("DeleteImageRegistry failed for `%s'", tmpnam); + rb_warn("DeleteImageRegistry failed for `%s'", temp_name); } #else long registry_id = -1; - sscanf(tmpnam, "mpri:%ld", &registry_id); + sscanf(temp_name, "mpri:%ld", &registry_id); if (registry_id >= 0) { (void) DeleteMagickRegistry(registry_id); } #endif @@ -3209,11 +3209,11 @@ the "loc" string in the @magick_location instance variable */ VALUE ImageMagickError_initialize(int argc, VALUE *argv, VALUE self) { - volatile VALUE super_argv[1] = {(VALUE)0}; + VALUE super_argv[1] = {(VALUE)0}; int super_argc = 0; volatile VALUE extra = Qnil; switch(argc) { @@ -3226,10 +3226,10 @@ break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc); } - (void) rb_call_super(super_argc, (VALUE *)super_argv); + (void) rb_call_super(super_argc, (const VALUE *)super_argv); (void) rb_iv_set(self, "@"MAGICK_LOC, extra); return self; }