Commits

Anonymous committed 41f75f4

- Use gdMalloc and gdFree

  • Participants
  • Parent commits 3a3fc73
  • Branches GD-2.0

Comments (0)

Files changed (1)

 
 tiff_handle *new_tiff_handle(tiff_handle *t, gdIOCtx *g)
 {
-	t = malloc(sizeof(tiff_handle));
+	t = gdMalloc(sizeof(tiff_handle));
 
 	t->size = 0;
 	t->pos = 0;
 
 	/* build the color map for 8 bit images */
 	if(bitDepth != 24) {
-		colorMapRed = malloc(3 * pow(2, bitsPerSample));
-		colorMapGreen = malloc(3 * pow(2, bitsPerSample));
-		colorMapBlue = malloc(3 * pow(2, bitsPerSample));
+		colorMapRed = gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapGreen = gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapBlue = gdMalloc(3 * pow(2, bitsPerSample));
 
 		for(i = 0; i < image->colorsTotal; i++) {
 			colorMapRed[i] = gdImageRed(image,i) + (gdImageRed(image,i) * 256);
 	TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1);
 
 	/* loop through y-coords, and x-coords */
-	scan = malloc(width * samplesPerPixel);
+	scan = gdMalloc(width * samplesPerPixel);
 	for(y = 0; y < height; y++) {
 		for(x = 0; x < width; x++) {
 			/* generate scan line for writing to tiff */
 
 	/* now cloase and free up resources */
 	TIFFClose(tiff);
-	free(scan);
-	free(th);
+	gdFree(scan);
+	gdFree(th);
 
 	if(bitDepth != 24) {
-		free(colorMapRed);
-		free(colorMapGreen);
-		free(colorMapBlue);
+		gdFree(colorMapRed);
+		gdFree(colorMapGreen);
+		gdFree(colorMapBlue);
 	}
 }
 
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		scan = malloc(tileSize);
+		scan = gdMalloc(tileSize);
 		tileX = 0;
 		tileY = 0;
 		for(tileNum = 0; tileNum < numberOfTiles; tileNum++) {
 			}
 		}
 
-		free(scan);
+		gdFree(scan);
 
 	} else {
 		/* image is not tiled - assume stripped (scanline) format */
 		printf("is a 1bit scanline tiff!\n");
-		scan = malloc(TIFFScanlineSize(tiff));
+		scan = gdMalloc(TIFFScanlineSize(tiff));
 		y = x = 0;
 
 		for(i = 0; i < height; i++) {
 			x=0;
 		}
 
-		free(scan);
+		gdFree(scan);
 	}
 
 	return im;
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		scan = malloc(tileSize);
+		scan = gdMalloc(tileSize);
 		tileX=0;
 		tileY=0;
 
 			}
 		}
 
-		free(scan);
+		gdFree(scan);
 
 	} else {
-		scan = malloc(TIFFScanlineSize(tiff));     
+		scan = gdMalloc(TIFFScanlineSize(tiff));     
 		y=0;
 		x=0;
 
 			x=0;
 		}
 
-		free(scan);
+		gdFree(scan);
 	}
 
 	return im;
 		}
 	}
 
-	free(scan);
+	gdFree(scan);
 
 	/* now reset colour merge for alpha blending routines */
 	gdImageAlphaBlending(im, alphaBlendingFlag);
 	}
 
 	TIFFClose(tiff);
-	free(th);
+	gdFree(th);
 
 	return im;
 }