Permalink
Browse files

- eliminate unused variables and static functions

- simplify some XS code by adding another typemap entry
  • Loading branch information...
1 parent e1d57e9 commit a659442a40580d9c53e6ee52e9941560b53fb709 Tony Cook committed Jan 24, 2005
Showing with 73 additions and 173 deletions.
  1. +2 −0 Changes
  2. +38 −50 Imager.xs
  3. +4 −8 bmp.c
  4. +1 −4 draw.c
  5. +0 −1 draw.h
  6. +0 −7 fills.c
  7. +0 −1 filters.c
  8. +0 −3 font.c
  9. +0 −5 freetyp2.c
  10. +2 −4 gif.c
  11. +5 −9 io.c
  12. +0 −1 iolayer.c
  13. +0 −1 jpeg.c
  14. +1 −1 map.c
  15. +0 −1 maskimg.c
  16. +1 −3 palimg.c
  17. +0 −2 png.c
  18. +0 −5 pnm.c
  19. +6 −16 polygon.c
  20. +3 −6 quant.c
  21. +0 −2 raw.c
  22. +1 −4 rgb.c
  23. +0 −1 rotate.c
  24. +2 −24 tags.c
  25. +2 −8 tga.c
  26. +1 −6 tiff.c
  27. +4 −0 typemap
View
@@ -1009,6 +1009,8 @@ Revision history for Perl extension Imager.
- explicitly document there are no PNG specific tags.
- more examples in Imager::Draw
- minor cleanup of Imager::Fill
+- eliminate unused variables and static functions
+- simplify some XS code by adding another typemap entry
=================================================================
View
@@ -18,6 +18,7 @@ typedef io_glue* Imager__IO;
typedef i_color* Imager__Color;
typedef i_fcolor* Imager__Color__Float;
typedef i_img* Imager__ImgRaw;
+typedef int undef_neg_int;
#ifdef HAVE_LIBTT
typedef TT_Fonthandle* Imager__Font__TT;
@@ -558,6 +559,7 @@ static struct value_name orddith_names[] =
{ "custom", od_custom, },
};
+#if 0
static int
hv_fetch_bool(HV *hv, char *name, int def) {
SV **sv;
@@ -581,6 +583,7 @@ hv_fetch_int(HV *hv, char *name, int def) {
else
return def;
}
+#endif
/* look through the hash for quantization options */
static void handle_quant_opts(i_quantize *quant, HV *hv)
@@ -845,7 +848,6 @@ load_fount_segs(AV *asegs, int *count) {
*/
int i, j;
AV *aseg;
- SV *sv;
i_fountain_seg *segs;
double work[3];
int worki[2];
@@ -1961,7 +1963,7 @@ i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8)
RETVAL
-undef_int
+void
i_tt_bbox(handle,point,str_sv,len_ignored, utf8)
Imager::Font::TT handle
float point
@@ -2619,8 +2621,6 @@ void
i_readgif_callback(...)
PROTOTYPE: &
PREINIT:
- char* data;
- int length;
int* colour_table;
int colours, q, w;
i_img* rimg;
@@ -3332,11 +3332,6 @@ DSO_call(handle,func_index,hv)
-# this is mostly for testing...
-# this function results in 'RETVAL' : unreferenced local variable
-# in VC++, and might be subtley wrong
-# the most obvious change may result in a double free so I'm leaving it
-# for now
SV *
i_get_pixel(im, x, y)
Imager::ImgRaw im
@@ -3347,13 +3342,15 @@ i_get_pixel(im, x, y)
CODE:
color = (i_color *)mymalloc(sizeof(i_color));
if (i_gpix(im, x, y, color) == 0) {
- ST(0) = sv_newmortal();
- sv_setref_pv(ST(0), "Imager::Color", (void *)color);
+ RETVAL = NEWSV(0, 0);
+ sv_setref_pv(RETVAL, "Imager::Color", (void *)color);
}
else {
myfree(color);
- ST(0) = &PL_sv_undef;
+ RETVAL = &PL_sv_undef;
}
+ OUTPUT:
+ RETVAL
int
@@ -3475,14 +3472,16 @@ i_addcolors(im, ...)
index = i_addcolors(im, colors, items-1);
myfree(colors);
if (index == 0) {
- ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+ RETVAL = newSVpv("0 but true", 0);
}
else if (index == -1) {
- ST(0) = &PL_sv_undef;
+ RETVAL = &PL_sv_undef;
}
else {
- ST(0) = sv_2mortal(newSViv(index));
+ RETVAL = newSViv(index);
}
+ OUTPUT:
+ RETVAL
undef_int
i_setcolors(im, index, ...)
@@ -3540,33 +3539,13 @@ i_getcolors(im, index, ...)
myfree(colors);
-SV *
+undef_neg_int
i_colorcount(im)
Imager::ImgRaw im
- PREINIT:
- int count;
- CODE:
- count = i_colorcount(im);
- if (count >= 0) {
- ST(0) = sv_2mortal(newSViv(count));
- }
- else {
- ST(0) = &PL_sv_undef;
- }
-SV *
+undef_neg_int
i_maxcolors(im)
Imager::ImgRaw im
- PREINIT:
- int count;
- CODE:
- count = i_maxcolors(im);
- if (count >= 0) {
- ST(0) = sv_2mortal(newSViv(count));
- }
- else {
- ST(0) = &PL_sv_undef;
- }
SV *
i_findcolor(im, color)
@@ -3576,11 +3555,13 @@ i_findcolor(im, color)
i_palidx index;
CODE:
if (i_findcolor(im, color, &index)) {
- ST(0) = sv_2mortal(newSViv(index));
+ RETVAL = newSViv(index);
}
else {
- ST(0) = &PL_sv_undef;
+ RETVAL = &PL_sv_undef;
}
+ OUTPUT:
+ RETVAL
int
i_img_bits(im)
@@ -3777,14 +3758,16 @@ i_gpixf(im, x, y)
CODE:
color = (i_fcolor *)mymalloc(sizeof(i_fcolor));
if (i_gpixf(im, x, y, color) == 0) {
- ST(0) = sv_newmortal();
- sv_setref_pv(ST(0), "Imager::Color::Float", (void *)color);
+ RETVAL = NEWSV(0,0);
+ sv_setref_pv(RETVAL, "Imager::Color::Float", (void *)color);
}
else {
myfree(color);
- ST(0) = &PL_sv_undef;
+ RETVAL = &PL_sv_undef;
}
-
+ OUTPUT:
+ RETVAL
+
void
i_glin(im, l, r, y)
Imager::ImgRaw im
@@ -3897,12 +3880,14 @@ i_tags_find(im, name, start)
CODE:
if (i_tags_find(&im->tags, name, start, &entry)) {
if (entry == 0)
- ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+ RETVAL = newSVpv("0 but true", 0);
else
- ST(0) = sv_2mortal(newSViv(entry));
+ RETVAL = newSViv(entry);
} else {
- ST(0) = &PL_sv_undef;
+ RETVAL = &PL_sv_undef;
}
+ OUTPUT:
+ RETVAL
SV *
i_tags_findn(im, code, start)
@@ -3914,12 +3899,15 @@ i_tags_findn(im, code, start)
CODE:
if (i_tags_findn(&im->tags, code, start, &entry)) {
if (entry == 0)
- ST(0) = sv_2mortal(newSVpv("0 but true", 0));
+ RETVAL = newSVpv("0 but true", 0);
else
- ST(0) = sv_2mortal(newSViv(entry));
+ RETVAL = newSViv(entry);
}
- else
- ST(0) = &PL_sv_undef;
+ else {
+ RETVAL = &PL_sv_undef;
+ }
+ OUTPUT:
+ RETVAL
int
i_tags_delete(im, entry)
View
12 bmp.c
@@ -516,7 +516,7 @@ static int
write_8bit_data(io_glue *ig, i_img *im) {
i_palidx *line;
int line_size = im->xsize;
- int x, y;
+ int y;
/* round up to nearest multiple of four */
line_size = (line_size + 3) / 4 * 4;
@@ -558,7 +558,7 @@ static int
write_24bit_data(io_glue *ig, i_img *im) {
int *chans;
unsigned char *samples;
- int x, y;
+ int y;
int line_size = 3 * im->xsize;
line_size = (line_size + 3) / 4 * 4;
@@ -632,7 +632,7 @@ read_1bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
i_palidx *line, *p;
unsigned char *packed;
int line_size = (xsize + 7)/8;
- int byte, bit;
+ int bit;
unsigned char *in;
long base_offset;
@@ -826,7 +826,6 @@ read_4bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
}
else if (compression == BI_RLE4) {
int read_size;
- int want_high;
int count;
i_tags_add(&im->tags, "bmp_compression_name", 0, "BI_RLE4", -1, 0);
@@ -921,9 +920,8 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
int compression, long offbits) {
i_img *im;
int x, y, lasty, yinc;
- i_palidx *line, *p;
+ i_palidx *line;
int line_size = xsize;
- unsigned char *in;
long base_offset;
line_size = (line_size+3) / 4 * 4;
@@ -992,7 +990,6 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
}
else if (compression == BI_RLE8) {
int read_size;
- int want_high;
int count;
unsigned char packed[2];
@@ -1093,7 +1090,6 @@ read_direct_bmp(io_glue *ig, int xsize, int ysize, int bit_count,
i_img *im;
int x, y, lasty, yinc;
i_color *line, *p;
- unsigned char *in;
int pix_size = bit_count / 8;
int line_size = xsize * pix_size;
struct bm_masks masks;
View
5 draw.c
@@ -247,7 +247,6 @@ make_minmax_list(i_mmarray *dot, float x, float y, float radius) {
polar_to_plane(x, y, angle, radius, &sx, &sy);
for(angle = 0.0; angle<361; angle +=astep) {
- float alpha;
lx = sx; ly = sy;
polar_to_plane(x, y, angle, radius, &cx, &cy);
sx = cx; sy = cy;
@@ -315,7 +314,7 @@ i_circle_aa(i_img *im, float x, float y, float rad, i_color *val) {
make_minmax_list(&dot, x, y, rad);
for(ly = 0; ly<im->ysize; ly++) {
- int ix, cy, cnt = 0, minx = INT_MAX, maxx = INT_MIN;
+ int ix, cy, minx = INT_MAX, maxx = INT_MIN;
/* Find the left/rightmost set subpixels */
for(cy = 0; cy<16; cy++) {
@@ -443,7 +442,6 @@ i_line(i_img *im, int x1, int y1, int x2, int y2, i_color *val, int endp) {
int x, y;
int dx, dy;
int p;
- unsigned char *cp;
dx = x2 - x1;
dy = y2 - y1;
@@ -632,7 +630,6 @@ i_line_aa(i_img *im, int x1, int y1, int x2, int y2, i_color *val, int endp) {
int x, y;
int dx, dy;
int p;
- unsigned char *cp;
dx = x2 - x1;
dy = y2 - y1;
View
1 draw.h
@@ -17,7 +17,6 @@ void i_mmarray_add(i_mmarray *ar,int x,int y);
int i_mmarray_gmin(i_mmarray *ar,int y);
int i_mmarray_getm(i_mmarray *ar,int y);
void i_mmarray_render(i_img *im,i_mmarray *ar,i_color *val);
-static void i_arcdraw(int x1, int y1, int x2, int y2, i_mmarray *ar);
void i_mmarray_info(i_mmarray *ar);
void i_arc(i_img *im,int x,int y,float rad,float d1,float d2,i_color *val);
void i_box(i_img *im,int x0,int y0,int x1,int y1,i_color *val);
View
@@ -726,7 +726,6 @@ static void fill_image(i_fill_t *fill, int x, int y, int width, int channels,
i_color *data) {
struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
int i = 0;
- i_color c;
i_color *out = data;
if (f->has_matrix) {
@@ -824,7 +823,6 @@ static void fill_imagef(i_fill_t *fill, int x, int y, int width, int channels,
i_fcolor *data) {
struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
int i = 0;
- i_fcolor c;
if (f->has_matrix) {
/* the hard way */
@@ -1050,7 +1048,6 @@ static void combine_mult(i_color *out, i_color *in, int channels, int count) {
int ch;
while (count--) {
- i_color c = *in;
double mult[MAXCHANNELS];
mult[3] = in->channel[3];
for (ch = 0; ch < (channels); ++ch) {
@@ -1079,8 +1076,6 @@ static void combine_multf(i_fcolor *out, i_fcolor *in, int channels, int count)
}
static void combine_dissolve(i_color *out, i_color *in, int channels, int count) {
- int ch;
-
while (count--) {
if (in->channel[3] > rand() * (255.0 / RAND_MAX))
COMBINE(*out, *in, channels);
@@ -1090,8 +1085,6 @@ static void combine_dissolve(i_color *out, i_color *in, int channels, int count)
}
static void combine_dissolvef(i_fcolor *out, i_fcolor *in, int channels, int count) {
- int ch;
-
while (count--) {
if (in->channel[3] > rand() * (1.0 / RAND_MAX))
COMBINEF(*out, *in, channels);
View
@@ -1216,7 +1216,6 @@ i_diff_image(i_img *im1, i_img *im2, int mindiff) {
i_img *out;
int outchans, diffchans;
int xsize, ysize;
- i_img temp;
i_clear_error();
if (im1->channels != im2->channels) {
View
3 font.c
@@ -488,7 +488,6 @@ i_t1_has_chars(int font_num, const char *text, int len, int utf8,
while (len) {
unsigned long c;
- int index;
if (utf8) {
c = i_utf8_advance(&text, &len);
if (c == ~0UL) {
@@ -1247,7 +1246,6 @@ int
i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8,
char *out) {
int count = 0;
- int inst;
mm_log((1, "i_tt_has_chars(handle %p, text %p, len %d, utf8 %d)\n",
handle, text, len, utf8));
@@ -1381,7 +1379,6 @@ i_tt_render_all_glyphs( TT_Fonthandle *handle, int inst, TT_Raster_Map *bit,
TT_Raster_Map *small_bit, int cords[6],
char const* txt, int len, int smooth, int utf8 ) {
unsigned long j;
- int i;
TT_F26Dot6 x,y;
mm_log((1,"i_tt_render_all_glyphs( handle 0x%X, inst %d, bit 0x%X, small_bit 0x%X, txt '%.*s', len %d, smooth %d, utf8 %d)\n",
Oops, something went wrong.

0 comments on commit a659442

Please sign in to comment.