ext/RMagick/rmutil.c in rmagick-2.9.2 vs ext/RMagick/rmutil.c in rmagick-2.10.0

- old
+ new

@@ -1,6 +1,6 @@ -/* $Id: rmutil.c,v 1.178 2009/02/28 23:50:36 rmagick Exp $ */ +/* $Id: rmutil.c,v 1.179 2009/06/03 23:08:31 rmagick Exp $ */ /*============================================================================\ | Copyright (C) 2009 by Timothy P. Hunter | Name: rmutil.c | Author: Tim Hunter | Purpose: Utility functions for RMagick @@ -25,31 +25,18 @@ compatible with prior releases. */ void * magick_safe_malloc(const size_t count, const size_t quantum) { -#if defined(HAVE_ACQUIREQUANTUMMEMORY) void *ptr; ptr = AcquireQuantumMemory(count, quantum); if (!ptr) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } return ptr; -#else - - // Provide an implementation of AcquireQuantumMemory in releases prior to 6.3.5-9. - size_t size = count * quantum; - - if (count == 0 || quantum != (size/count)) - { - rb_raise(rb_eRuntimeError, "integer overflow detected in memory size computation. " - "Probable image corruption."); - } - return magick_malloc(size); -#endif } void * magick_malloc(const size_t size) @@ -73,28 +60,17 @@ void * magick_safe_realloc(void *memory, const size_t count, const size_t quantum) { -#if defined(HAVE_RESIZEQUANTUMMEMORY) void *v; v = ResizeQuantumMemory(memory, count, quantum); if (!v) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } return v; -#else - // Provide an implementation of ResizeQuantumMemory in releases prior to 6.3.5-9. - size_t size = count * quantum; - if (count == 0 || quantum != (size/count)) - { - rb_raise(rb_eRuntimeError, "integer overflow detected in memory size computation. " - "Probable image corruption."); - } - return magick_realloc(memory, size); -#endif } void * magick_realloc(void *ptr, const size_t size) @@ -574,11 +550,10 @@ */ void rm_write_temp_image(Image *image, char *temp_name) { -#if defined(HAVE_SETIMAGEREGISTRY) #define TMPNAM_CLASS_VAR "@@_tmpnam_" MagickBooleanType okay; ExceptionInfo exception; volatile VALUE id_value; @@ -610,28 +585,10 @@ if (!okay) { rb_raise(rb_eRuntimeError, "SetImageRegistry failed."); } -#else - - long registry_id; - - rb_warn("`%s' can cause memory leaks with ImageMagick " MagickLibVersionText - ".\nUpgrade to ImageMagick 6.3.4-10 or later to prevent this behavior." - , rb_id2name(THIS_FUNC())); - - registry_id = SetMagickRegistry(ImageRegistryType, image, sizeof(Image), &image->exception); - rm_check_image_exception(image, RetainOnError); - if (registry_id < 0) - { - rb_raise(rb_eRuntimeError, "SetMagickRegistry failed."); - } - - sprintf(temp_name, "mpri:%ld", registry_id); -#endif - } /* External: delete_temp_image @@ -735,33 +692,22 @@ Purpose: Backport GetImageProperty for pre-6.3.1 versions of ImageMagick */ const char * rm_get_property(const Image *img, const char *property) { -#if defined(HAVE_GETIMAGEPROPERTY) return GetImageProperty(img, property); -#else - const ImageAttribute *attr; - - attr = GetImageAttribute(img, property); - return attr ? (const char *)attr->value : NULL; -#endif } /* Function: rm_set_property Purpose: Backport SetImageProperty for pre-6.3.1 versions of ImageMagick */ MagickBooleanType rm_set_property(Image *image, const char *property, const char *value) { -#if defined(HAVE_SETIMAGEPROPERTY) return SetImageProperty(image, property, value); -#else - return SetImageAttribute(image, property, value); -#endif } /* Function: rm_set_user_artifact @@ -952,17 +898,15 @@ if (option) { image->scene = info->scene; } -#if defined(HAVE_ST_TILE_OFFSET) option = GetImageOption(info, "tile-offset"); if (option) { (void)ParseAbsoluteGeometry(option, &image->tile_offset); } -#endif option = GetImageOption(info, "transparent"); if (option) { image->transparent_color = info->transparent_color; @@ -1022,11 +966,10 @@ Notes: see magick/identify.c */ VALUE rm_exif_by_entry(Image *image) { -#if defined(HAVE_GETIMAGEPROPERTY) const char *property, *value; char *str; size_t len = 0, property_l, value_l; volatile VALUE v; @@ -1091,17 +1034,10 @@ } v = rb_str_new(str, len); xfree(str); return v; - -#else - - const char *attr = rm_get_property(image, "EXIF:*"); - return attr ? rb_str_new2(attr) : Qnil; - -#endif } /* Function: rm_exif_by_number @@ -1112,11 +1048,10 @@ Notes: see magick/identify.c */ VALUE rm_exif_by_number(Image *image) { -#if defined(HAVE_GETIMAGEPROPERTY) const char *property, *value; char *str; size_t len = 0, property_l, value_l; volatile VALUE v; @@ -1181,16 +1116,9 @@ } v = rb_str_new(str, len); xfree(str); return v; - -#else - - const char *attr = rm_get_property(image, "EXIF:!"); - return attr ? rb_str_new2(attr) : Qnil; - -#endif } /* * Extern: rm_get_geometry