Permalink
Browse files

Consitfy const char* filename in msSaveImage(), msSaveImageIM() and m…

…sSaveImageGDAL()
  • Loading branch information...
rouault committed Dec 1, 2017
1 parent 66d8e0a commit 924f2e4aa9a210f5fbd9d1a062a96428e1cdb773
Showing with 19 additions and 13 deletions.
  1. +14 −8 mapgdal.c
  2. +1 −1 mapimagemap.c
  3. +3 −3 mapserver.h
  4. +1 −1 maputil.c
@@ -143,7 +143,7 @@ void CleanVSIDir( const char *pszDir )
/* msSaveImageGDAL() */
/************************************************************************/
int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filenameIn )
{
int bFileIsTemporary = MS_FALSE;
@@ -157,6 +157,8 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
rasterBufferObj rb;
GDALDataType eDataType = GDT_Byte;
int bUseXmp = MS_FALSE;
const char *filename = NULL;
char *filenameToFree = NULL;
msGDALInitialize();
memset(&rb,0,sizeof(rasterBufferObj));
@@ -187,25 +189,29 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
/* memory, otherwise we try to put it in a reasonable temporary */
/* file location. */
/* -------------------------------------------------------------------- */
if( filename == NULL ) {
if( filenameIn == NULL ) {
const char *pszExtension = format->extension;
if( pszExtension == NULL )
pszExtension = "img.tmp";
if( bUseXmp == MS_FALSE && GDALGetMetadataItem( hOutputDriver, GDAL_DCAP_VIRTUALIO, NULL )
!= NULL ) {
CleanVSIDir( "/vsimem/msout" );
filename = msTmpFile(map, NULL, "/vsimem/msout/", pszExtension );
filenameToFree = msTmpFile(map, NULL, "/vsimem/msout/", pszExtension );
}
if( filename == NULL && map != NULL)
filename = msTmpFile(map, map->mappath,NULL,pszExtension);
else if( filename == NULL ) {
filename = msTmpFile(map, NULL, NULL, pszExtension );
if( filenameToFree == NULL && map != NULL)
filenameToFree = msTmpFile(map, map->mappath,NULL,pszExtension);
else if( filenameToFree == NULL ) {
filenameToFree = msTmpFile(map, NULL, NULL, pszExtension );
}
filename = filenameToFree;
bFileIsTemporary = MS_TRUE;
}
else {
filename = filenameIn;
}
/* -------------------------------------------------------------------- */
/* Establish the characteristics of our memory, and final */
@@ -503,7 +509,7 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
VSIUnlink( filename );
CleanVSIDir( "/vsimem/msout" );
free( filename );
msFree( filenameToFree );
}
return MS_SUCCESS;
@@ -641,7 +641,7 @@ int msDrawTextIM(mapObj *map, imageObj* img, pointObj labelPnt, char *string, la
* Save an image to a file named filename, if filename is NULL it goes to stdout
*/
int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format )
int msSaveImageIM(imageObj* img, const char *filename, outputFormatObj *format )
{
FILE *stream;
@@ -1991,7 +1991,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
#endif /*SWIG*/
/* Function prototypes, wrapable */
MS_DLL_EXPORT int msSaveImage(mapObj *map, imageObj *img, char *filename);
MS_DLL_EXPORT int msSaveImage(mapObj *map, imageObj *img, const char *filename);
MS_DLL_EXPORT void msFreeImage(imageObj *img);
MS_DLL_EXPORT int msSetup(void);
MS_DLL_EXPORT void msCleanup(void);
@@ -2592,7 +2592,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
/* ==================================================================== */
MS_DLL_EXPORT imageObj *msImageCreateIM(int width, int height, outputFormatObj *format, char *imagepath, char *imageurl, double resolution, double defresolution);
MS_DLL_EXPORT void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image);
MS_DLL_EXPORT int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format);
MS_DLL_EXPORT int msSaveImageIM(imageObj* img, const char *filename, outputFormatObj *format);
MS_DLL_EXPORT void msFreeImageIM(imageObj* img);
MS_DLL_EXPORT void msDrawMarkerSymbolIM(mapObj *map, imageObj* img, pointObj *p, styleObj *style, double scalefactor);
MS_DLL_EXPORT void msDrawLineSymbolIM(mapObj *map, imageObj* img, shapeObj *p, styleObj *style, double scalefactor);
@@ -2770,7 +2770,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
/* ==================================================================== */
/* prototypes for functions in mapgdal.c */
/* ==================================================================== */
MS_DLL_EXPORT int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename );
MS_DLL_EXPORT int msSaveImageGDAL( mapObj *map, imageObj *image, const char *filename );
MS_DLL_EXPORT int msInitDefaultGDALOutputFormat( outputFormatObj *format );
/* ==================================================================== */
@@ -826,7 +826,7 @@ int msConstrainExtent(rectObj *bounds, rectObj *rect, double overlay)
** The filename is NULL when the image is supposed to be written to stdout.
*/
int msSaveImage(mapObj *map, imageObj *img, char *filename)
int msSaveImage(mapObj *map, imageObj *img, const char *filename)
{
int nReturnVal = MS_FAILURE;
char szPath[MS_MAXPATHLEN];

0 comments on commit 924f2e4

Please sign in to comment.