Permalink
Browse files

const-correctness

Add "const" to a bunch of pointers that are not written to.
  • Loading branch information...
MaxKellermann committed Mar 27, 2014
1 parent 77313de commit c69d113b21f26b5d45cf40e672c3bf1a71507f7f
Showing with 20 additions and 19 deletions.
  1. +2 −2 mapbits.c
  2. +2 −2 mapsearch.c
  3. +5 −4 mapserver.h
  4. +1 −1 mapshape.c
  5. +1 −1 mapshape.h
  6. +2 −2 maptree.c
  7. +2 −2 maptree.h
  8. +5 −5 mapxbase.c
View
@@ -55,7 +55,7 @@ ms_bitarray msAllocBitArray(int numbits)
return(array);
}
int msGetBit(ms_bitarray array, int index)
int msGetBit(ms_const_bitarray array, int index)
{
array += index / MS_ARRAY_BIT;
return (*array & (1 << (index % MS_ARRAY_BIT))) != 0; /* 0 or 1 */
@@ -68,7 +68,7 @@ int msGetBit(ms_bitarray array, int index)
** If hits end of bitmap without finding set bit, will return -1.
**
*/
int msGetNextBit(ms_bitarray array, int i, int size)
int msGetNextBit(ms_const_bitarray array, int i, int size)
{
register ms_uint32 b;
View
@@ -77,7 +77,7 @@ int msRectIntersect( rectObj *a, const rectObj *b )
/*
** Returns MS_TRUE if rectangle a is contained in rectangle b
*/
int msRectContained(rectObj *a, rectObj *b)
int msRectContained(const rectObj *a, const rectObj *b)
{
if(a->minx >= b->minx && a->maxx <= b->maxx)
if(a->miny >= b->miny && a->maxy <= b->maxy)
@@ -96,7 +96,7 @@ void msMergeRect(rectObj *a, rectObj *b)
a->maxy = MS_MAX(a->maxy, b->maxy);
}
int msPointInRect(pointObj *p, rectObj *rect)
int msPointInRect(const pointObj *p, const rectObj *rect)
{
if(p->x < rect->minx) return(MS_FALSE);
if(p->x > rect->maxx) return(MS_FALSE);
View
@@ -121,6 +121,7 @@ typedef struct face_element face_element;
/* ms_bitarray is used by the bit mask in mapbit.c */
typedef ms_uint32 * ms_bitarray;
typedef const ms_uint32 *ms_const_bitarray;
#include "maperror.h"
#include "mapprimitive.h"
@@ -2079,9 +2080,9 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
MS_DLL_EXPORT double msInchesPerUnit(int units, double center_lat);
MS_DLL_EXPORT int msEmbedScalebar(mapObj *map, imageObj *img);
MS_DLL_EXPORT int msPointInRect(pointObj *p, rectObj *rect); /* in mapsearch.c */
MS_DLL_EXPORT int msPointInRect(const pointObj *p, const rectObj *rect); /* in mapsearch.c */
MS_DLL_EXPORT int msRectOverlap(const rectObj *a, const rectObj *b);
MS_DLL_EXPORT int msRectContained(rectObj *a, rectObj *b);
MS_DLL_EXPORT int msRectContained(const rectObj *a, const rectObj *b);
MS_DLL_EXPORT int msRectIntersect(rectObj *a, const rectObj *b);
MS_DLL_EXPORT void msRectToFormattedString(rectObj *rect, char *format,
@@ -2337,11 +2338,11 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
MS_DLL_EXPORT size_t msGetBitArraySize(int numbits); /* in mapbits.c */
MS_DLL_EXPORT ms_bitarray msAllocBitArray(int numbits);
MS_DLL_EXPORT int msGetBit(ms_bitarray array, int index);
MS_DLL_EXPORT int msGetBit(ms_const_bitarray array, int index);
MS_DLL_EXPORT void msSetBit(ms_bitarray array, int index, int value);
MS_DLL_EXPORT void msSetAllBits(ms_bitarray array, int index, int value);
MS_DLL_EXPORT void msFlipBit(ms_bitarray array, int index);
MS_DLL_EXPORT int msGetNextBit(ms_bitarray array, int index, int size);
MS_DLL_EXPORT int msGetNextBit(ms_const_bitarray array, int index, int size);
/* maplayer.c - layerObj api */
View
@@ -1696,7 +1696,7 @@ int msSHPReadBounds( SHPHandle psSHP, int hEntity, rectObj *padBounds)
return MS_SUCCESS;
}
int msShapefileOpen(shapefileObj *shpfile, char *mode, char *filename, int log_failures)
int msShapefileOpen(shapefileObj *shpfile, const char *mode, const char *filename, int log_failures)
{
int i;
char *dbfFilename;
View
@@ -182,7 +182,7 @@ extern "C" {
} msTiledSHPLayerInfo;
/* shapefileObj function prototypes */
MS_DLL_EXPORT int msShapefileOpen(shapefileObj *shpfile, char *mode, char *filename, int log_failures);
MS_DLL_EXPORT int msShapefileOpen(shapefileObj *shpfile, const char *mode, const char *filename, int log_failures);
MS_DLL_EXPORT int msShapefileCreate(shapefileObj *shpfile, char *filename, int type);
MS_DLL_EXPORT void msShapefileClose(shapefileObj *shpfile);
MS_DLL_EXPORT int msShapefileWhichShapes(shapefileObj *shpfile, rectObj rect, int debug);
View
@@ -399,7 +399,7 @@ static void treeCollectShapeIds(treeNodeObj *node, rectObj aoi, ms_bitarray stat
}
}
ms_bitarray msSearchTree(treeObj *tree, rectObj aoi)
ms_bitarray msSearchTree(const treeObj *tree, rectObj aoi)
{
ms_bitarray status=NULL;
@@ -511,7 +511,7 @@ static void searchDiskTreeNode(SHPTreeHandle disktree, rectObj aoi, ms_bitarray
return;
}
ms_bitarray msSearchDiskTree(char *filename, rectObj aoi, int debug)
ms_bitarray msSearchDiskTree(const char *filename, rectObj aoi, int debug)
{
SHPTreeHandle disktree;
ms_bitarray status=NULL;
View
@@ -84,8 +84,8 @@ extern "C" {
MS_DLL_EXPORT void msTreeTrim(treeObj *tree);
MS_DLL_EXPORT void msDestroyTree(treeObj *tree);
MS_DLL_EXPORT ms_bitarray msSearchTree(treeObj *tree, rectObj aoi);
MS_DLL_EXPORT ms_bitarray msSearchDiskTree(char *filename, rectObj aoi, int debug);
MS_DLL_EXPORT ms_bitarray msSearchTree(const treeObj *tree, rectObj aoi);
MS_DLL_EXPORT ms_bitarray msSearchDiskTree(const char *filename, rectObj aoi, int debug);
MS_DLL_EXPORT treeObj *msReadTree(char *filename, int debug);
MS_DLL_EXPORT int msWriteTree(treeObj *tree, char *filename, int LSB_order);
View
@@ -497,13 +497,13 @@ int DBFIsValueNULL( const char* pszValue, char type )
/* */
/* Read one of the attribute fields of a record. */
/************************************************************************/
static char *msDBFReadAttribute(DBFHandle psDBF, int hEntity, int iField )
static const char *msDBFReadAttribute(DBFHandle psDBF, int hEntity, int iField )
{
int i;
unsigned int nRecordOffset;
uchar *pabyRec;
char *pReturnField = NULL;
const uchar *pabyRec;
const char *pReturnField = NULL;
/* -------------------------------------------------------------------- */
/* Is the request valid? */
@@ -532,7 +532,7 @@ static char *msDBFReadAttribute(DBFHandle psDBF, int hEntity, int iField )
psDBF->nCurrentRecord = hEntity;
}
pabyRec = (uchar *) psDBF->pszCurrentRecord;
pabyRec = (const uchar *) psDBF->pszCurrentRecord;
/* DEBUG */
/* printf("CurrentRecord(%c):%s\n", psDBF->pachFieldType[iField], pabyRec); */
@@ -547,7 +547,7 @@ static char *msDBFReadAttribute(DBFHandle psDBF, int hEntity, int iField )
/* -------------------------------------------------------------------- */
/* Extract the requested field. */
/* -------------------------------------------------------------------- */
strncpy( psDBF->pszStringField,(char *) pabyRec+psDBF->panFieldOffset[iField], psDBF->panFieldSize[iField] );
strncpy( psDBF->pszStringField,(const char *) pabyRec+psDBF->panFieldOffset[iField], psDBF->panFieldSize[iField] );
psDBF->pszStringField[psDBF->panFieldSize[iField]] = '\0';
/*

0 comments on commit c69d113

Please sign in to comment.