summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPPM.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkImgPPM.c')
-rw-r--r--generic/tkImgPPM.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index 7aeeade..71f4481 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -13,7 +13,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPPM.c,v 1.21 2007/12/13 15:24:14 dgp Exp $
+ * RCS: @(#) $Id: tkImgPPM.c,v 1.23 2010/01/18 20:43:38 nijtmans Exp $
*/
#include "tkInt.h"
@@ -36,14 +36,14 @@
* The format record for the PPM file format:
*/
-static int FileMatchPPM(Tcl_Channel chan, CONST char *fileName,
+static int FileMatchPPM(Tcl_Channel chan, const char *fileName,
Tcl_Obj *format, int *widthPtr, int *heightPtr,
Tcl_Interp *interp);
static int FileReadPPM(Tcl_Interp *interp, Tcl_Channel chan,
- CONST char *fileName, Tcl_Obj *format,
+ const char *fileName, Tcl_Obj *format,
Tk_PhotoHandle imageHandle, int destX, int destY,
int width, int height, int srcX, int srcY);
-static int FileWritePPM(Tcl_Interp *interp, CONST char *fileName,
+static int FileWritePPM(Tcl_Interp *interp, const char *fileName,
Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
static int StringWritePPM(Tcl_Interp *interp, Tcl_Obj *format,
Tk_PhotoImageBlock *blockPtr);
@@ -62,6 +62,7 @@ Tk_PhotoImageFormat tkImgFmtPPM = {
StringReadPPM, /* stringReadProc */
FileWritePPM, /* fileWriteProc */
StringWritePPM, /* stringWriteProc */
+ NULL
};
/*
@@ -95,7 +96,7 @@ static int ReadPPMStringHeader(Tcl_Obj *dataObj, int *widthPtr,
static int
FileMatchPPM(
Tcl_Channel chan, /* The image file, open for reading. */
- CONST char *fileName, /* The name of the image file. */
+ const char *fileName, /* The name of the image file. */
Tcl_Obj *format, /* User-specified format string, or NULL. */
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
@@ -131,7 +132,7 @@ static int
FileReadPPM(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tcl_Channel chan, /* The image file, open for reading. */
- CONST char *fileName, /* The name of the image file. */
+ const char *fileName, /* The name of the image file. */
Tcl_Obj *format, /* User-specified format string, or NULL. */
Tk_PhotoHandle imageHandle, /* The photo image to write into. */
int destX, int destY, /* Coordinates of top-left pixel in photo
@@ -209,7 +210,7 @@ FileReadPPM(
nLines = 1;
}
nBytes = nLines * block.pitch;
- pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
+ pixelPtr = ckalloc(nBytes);
block.pixelPtr = pixelPtr + srcX * block.pixelSize;
for (h = height; h > 0; h -= nLines) {
@@ -223,7 +224,7 @@ FileReadPPM(
fileName, "\": ",
Tcl_Eof(chan) ? "not enough data" : Tcl_PosixError(interp),
NULL);
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
return TCL_ERROR;
}
if (maxIntensity != 255) {
@@ -236,13 +237,13 @@ FileReadPPM(
block.height = nLines;
if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
return TCL_ERROR;
}
destY += nLines;
}
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
return TCL_OK;
}
@@ -267,7 +268,7 @@ FileReadPPM(
static int
FileWritePPM(
Tcl_Interp *interp,
- CONST char *fileName,
+ const char *fileName,
Tcl_Obj *format,
Tk_PhotoImageBlock *blockPtr)
{
@@ -561,7 +562,7 @@ StringReadPPM(
nLines = 1;
}
nBytes = nLines * block.pitch;
- pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
+ pixelPtr = ckalloc(nBytes);
block.pixelPtr = pixelPtr + srcX * block.pixelSize;
for (h = height; h > 0; h -= nLines) {
@@ -572,7 +573,7 @@ StringReadPPM(
nBytes = nLines * block.pitch;
}
if (dataSize < nBytes) {
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
Tcl_AppendResult(interp, "truncated PPM data", NULL);
return TCL_ERROR;
}
@@ -583,13 +584,13 @@ StringReadPPM(
block.height = nLines;
if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY,
width, nLines, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
return TCL_ERROR;
}
destY += nLines;
}
- ckfree((char *) pixelPtr);
+ ckfree(pixelPtr);
return TCL_OK;
}