Update of /cvsroot/q-lang/q/modules/ggi
In directory sc8-pr-cvs1:/tmp/cvs-serv30674
Modified Files:
ggi.c
Log Message:
bug fixes: memory leaks in set_transform
Index: ggi.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ggi.c 20 Dec 2003 02:30:37 -0000 1.4
--- ggi.c 20 Dec 2003 02:41:44 -0000 1.5
***************
*** 1102,1120 ****
(isfloat(xv[2], &yx) || ismpz_float(xv[2], &yx)) &&
(isfloat(xv[3], &yy) || ismpz_float(xv[3], &yy))) {
! FT_Matrix *matrix = malloc(sizeof(FT_Matrix));
! FT_Vector *vect = malloc(sizeof(FT_Vector));
! if (!matrix || !vect) {
! if (matrix) free(matrix);
! if (vect) free(vect);
! return __ERROR;
}
- vect->x = (FT_Pos)(x*0x40);
- vect->y = (FT_Pos)(y*0x40);
- matrix->xx = (FT_Fixed)(xx*0x10000L);
- matrix->xy = (FT_Fixed)(xy*0x10000L);
- matrix->yx = (FT_Fixed)(yx*0x10000L);
- matrix->yy = (FT_Fixed)(yy*0x10000L);
- v->vect = vect;
- v->matrix = matrix;
return mkvoid;
} else
--- 1102,1131 ----
(isfloat(xv[2], &yx) || ismpz_float(xv[2], &yx)) &&
(isfloat(xv[3], &yy) || ismpz_float(xv[3], &yy))) {
! if (x == 0.0 && y == 0.0 &&
! xx == 1.0 && xy == 0.0 && yx == 0.0 && yy == 1.0) {
! /* identity transform: remove any existing transform from the visual */
! if (v->vect) free(v->vect);
! if (v->matrix) free(v->matrix);
! v->vect = NULL;
! v->matrix = NULL;
! } else {
! FT_Matrix *matrix = malloc(sizeof(FT_Matrix));
! FT_Vector *vect = malloc(sizeof(FT_Vector));
! if (!matrix || !vect) {
! if (matrix) free(matrix);
! if (vect) free(vect);
! return __ERROR;
! }
! vect->x = (FT_Pos)(x*0x40);
! vect->y = (FT_Pos)(y*0x40);
! matrix->xx = (FT_Fixed)(xx*0x10000L);
! matrix->xy = (FT_Fixed)(xy*0x10000L);
! matrix->yx = (FT_Fixed)(yx*0x10000L);
! matrix->yy = (FT_Fixed)(yy*0x10000L);
! if (v->vect) free(v->vect);
! if (v->matrix) free(v->matrix);
! v->vect = vect;
! v->matrix = matrix;
}
return mkvoid;
} else
|