Skip to content

Commit e22c9cd

Browse files
committed
fix valgrind error in test bug24594.phpt
while at it, remove some dead code and change the pts vector to char to save (much) memory # Pierre: one more to merge ;)
1 parent 2cca49a commit e22c9cd

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

ext/gd/libgd/gd.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,20 +2004,20 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)
20042004
/* stack of filled segments */
20052005
struct seg *stack;
20062006
struct seg *sp;
2007+
char **pts;
20072008

2008-
int **pts;
2009-
if(!im->tile){
2009+
if (!im->tile) {
20102010
return;
20112011
}
20122012

20132013
wx2=im->sx;wy2=im->sy;
20142014
tiled = nc==gdTiled;
20152015

20162016
nc = gdImageTileGet(im,x,y);
2017-
pts = (int **) ecalloc(sizeof(int *) * im->sy, sizeof(int));
2017+
pts = (char **) ecalloc(sizeof(char *) * im->sy, sizeof(char));
20182018

20192019
for (i=0; i<im->sy;i++) {
2020-
pts[i] = (int *) ecalloc(im->sx, sizeof(int));
2020+
pts[i] = (char *) ecalloc(im->sx, sizeof(char));
20212021
}
20222022

20232023
stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1);
@@ -2032,10 +2032,6 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)
20322032
while (sp>stack) {
20332033
FILL_POP(y, x1, x2, dy);
20342034
for (x=x1; x>=0 && (!pts[y][x] && gdImageGetPixel(im,x,y)==oc); x--) {
2035-
if (pts[y][x]){
2036-
/* we should never be here */
2037-
break;
2038-
}
20392035
nc = gdImageTileGet(im,x,y);
20402036
pts[y][x]=1;
20412037
gdImageSetPixel(im,x, y, nc);
@@ -2051,11 +2047,7 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)
20512047
}
20522048
x = x1+1;
20532049
do {
2054-
for (; x<=wx2 && (!pts[y][x] && gdImageGetPixel(im,x, y)==oc) ; x++) {
2055-
if (pts[y][x]){
2056-
/* we should never be here */
2057-
break;
2058-
}
2050+
for (; x<wx2 && (!pts[y][x] && gdImageGetPixel(im,x, y)==oc) ; x++) {
20592051
nc = gdImageTileGet(im,x,y);
20602052
pts[y][x]=1;
20612053
gdImageSetPixel(im, x, y, nc);

0 commit comments

Comments
 (0)