ext/RMagick/rminfo.c in rmagick-2.14.0 vs ext/RMagick/rminfo.c in rmagick-2.15.0
- old
+ new
@@ -315,11 +315,11 @@
*/
VALUE
Info_aset(int argc, VALUE *argv, VALUE self)
{
Info *info;
- volatile VALUE value;
+ VALUE value;
char *format_p, *key_p, *value_p = NULL;
long format_l, key_l;
char ckey[MaxTextExtent];
unsigned int okay;
@@ -371,10 +371,11 @@
rb_warn("`%s' not defined - SetImageOption failed.", ckey);
return Qnil;
}
}
+ RB_GC_GUARD(value);
return self;
}
@@ -743,11 +744,11 @@
char *format, *key;
const char *value = "";
long format_l, key_l;
char ckey[100];
unsigned int okay;
- volatile VALUE fmt_arg;
+ VALUE fmt_arg;
Data_Get_Struct(self, Info, info);
switch (argc)
{
@@ -775,10 +776,12 @@
{
rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value);
return Qnil;
}
+ RB_GC_GUARD(fmt_arg);
+
return self;
}
/**
* Get the delay attribute.
@@ -901,11 +904,11 @@
*/
VALUE
Info_density_eq(VALUE self, VALUE density_arg)
{
Info *info;
- volatile VALUE density;
+ VALUE density;
char *dens;
Data_Get_Struct(self, Info, info);
if (NIL_P(density_arg))
@@ -922,10 +925,12 @@
rb_raise(rb_eArgError, "invalid density geometry: %s", dens);
}
magick_clone_string(&info->density, dens);
+ RB_GC_GUARD(density);
+
return self;
}
/**
* Get the depth attribute
@@ -1187,11 +1192,11 @@
VALUE
Info_extract_eq(VALUE self, VALUE extract_arg)
{
Info *info;
char *extr;
- volatile VALUE extract;
+ VALUE extract;
Data_Get_Struct(self, Info, info);
if (NIL_P(extract_arg))
{
@@ -1207,10 +1212,12 @@
rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
}
magick_clone_string(&info->extract, extr);
+ RB_GC_GUARD(extract);
+
return self;
}
/**
@@ -1814,11 +1821,11 @@
*/
VALUE
Info_origin_eq(VALUE self, VALUE origin_arg)
{
Info *info;
- volatile VALUE origin_str;
+ VALUE origin_str;
char *origin;
Data_Get_Struct(self, Info, info);
if (NIL_P(origin_arg))
@@ -1834,10 +1841,13 @@
{
rb_raise(rb_eArgError, "invalid origin geometry: %s", origin);
}
(void) SetImageOption(info, "origin", origin);
+
+ RB_GC_GUARD(origin_str);
+
return self;
}
/**
@@ -1872,11 +1882,11 @@
*/
VALUE
Info_page_eq(VALUE self, VALUE page_arg)
{
Info *info;
- volatile VALUE geom_str;
+ VALUE geom_str;
char *geometry;
Data_Get_Struct(self, Info, info);
if (NIL_P(page_arg))
{
@@ -1892,10 +1902,12 @@
info->page = NULL;
return self;
}
magick_clone_string(&info->page, geometry);
+ RB_GC_GUARD(geom_str);
+
return self;
}
DEF_ATTR_ACCESSOR(Info, pointsize, dbl)
DEF_ATTR_ACCESSOR(Info, quality, ulong)
@@ -2079,11 +2091,11 @@
*/
VALUE
Info_size_eq(VALUE self, VALUE size_arg)
{
Info *info;
- volatile VALUE size;
+ VALUE size;
char *sz;
Data_Get_Struct(self, Info, info);
if (NIL_P(size_arg))
@@ -2100,10 +2112,12 @@
rb_raise(rb_eArgError, "invalid size geometry: %s", sz);
}
magick_clone_string(&info->size, sz);
+ RB_GC_GUARD(size);
+
return self;
}
/**
@@ -2233,11 +2247,11 @@
*/
VALUE
Info_tile_offset_eq(VALUE self, VALUE offset)
{
Info *info;
- volatile VALUE offset_str;
+ VALUE offset_str;
char *tile_offset;
offset_str = rm_to_s(offset);
tile_offset = StringValuePtr(offset_str);
if (!IsGeometry(tile_offset))
@@ -2247,10 +2261,13 @@
Data_Get_Struct(self, Info, info);
(void) DeleteImageOption(info, "tile-offset");
(void) SetImageOption(info, "tile-offset", tile_offset);
+
+ RB_GC_GUARD(offset_str);
+
return self;
}
/**
@@ -2511,18 +2528,21 @@
*/
VALUE
Info_alloc(VALUE class)
{
Info *info;
- volatile VALUE info_obj;
+ VALUE info_obj;
info = CloneImageInfo(NULL);
if (!info)
{
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
}
info_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
+
+ RB_GC_GUARD(info_obj);
+
return info_obj;
}
/**
@@ -2536,12 +2556,15 @@
* @return a new ImageInfo object
*/
VALUE
rm_info_new(void)
{
- volatile VALUE info_obj;
+ VALUE info_obj;
info_obj = Info_alloc(Class_Info);
+
+ RB_GC_GUARD(info_obj);
+
return Info_initialize(info_obj);
}
/**