Code cleanups

on behalf of Lebedev, see issue 1279
This commit is contained in:
Oliver Duis 2012-03-16 15:22:27 +01:00
parent d520543462
commit 2a507c8615
9 changed files with 62 additions and 62 deletions

View File

@ -262,7 +262,7 @@ public:
array2D<T> & operator[](int index) { array2D<T> & operator[](int index) {
if (static_cast<size_t>(index) >= num) { if (static_cast<size_t>(index) >= num) {
printf("index %0u is out of range[0..%0u]", index, num - 1); printf("index %0u is out of range[0..%0lu]", index, num - 1);
raise( SIGSEGV); raise( SIGSEGV);
} }
return list[index]; return list[index];

View File

@ -20,7 +20,7 @@
* exactly like printf * exactly like printf
*/ */
void KLTError(char *fmt, ...) void KLTError(const char *fmt, ...)
{ {
va_list args; va_list args;
@ -42,7 +42,7 @@ void KLTError(char *fmt, ...)
* exactly like printf * exactly like printf
*/ */
void KLTWarning(char *fmt, ...) void KLTWarning(const char *fmt, ...)
{ {
va_list args; va_list args;

View File

@ -8,8 +8,8 @@
#include <cstdio> #include <cstdio>
#include <cstdarg> #include <cstdarg>
void KLTError(char *fmt, ...); void KLTError(const char *fmt, ...);
void KLTWarning(char *fmt, ...); void KLTWarning(const char *fmt, ...);
#endif #endif

View File

@ -209,28 +209,28 @@ void KLTWriteFeatureListToPPM(
KLT_PixelType *greyimg, KLT_PixelType *greyimg,
int ncols, int ncols,
int nrows, int nrows,
char *filename); const char *filename);
void KLTWriteFeatureList( void KLTWriteFeatureList(
KLT_FeatureList fl, KLT_FeatureList fl,
char *filename, const char *filename,
char *fmt); const char *fmt);
void KLTWriteFeatureHistory( void KLTWriteFeatureHistory(
KLT_FeatureHistory fh, KLT_FeatureHistory fh,
char *filename, const char *filename,
char *fmt); const char *fmt);
void KLTWriteFeatureTable( void KLTWriteFeatureTable(
KLT_FeatureTable ft, KLT_FeatureTable ft,
char *filename, const char *filename,
char *fmt); const char *fmt);
KLT_FeatureList KLTReadFeatureList( KLT_FeatureList KLTReadFeatureList(
KLT_FeatureList fl, KLT_FeatureList fl,
char *filename); const char *filename);
KLT_FeatureHistory KLTReadFeatureHistory( KLT_FeatureHistory KLTReadFeatureHistory(
KLT_FeatureHistory fh, KLT_FeatureHistory fh,
char *filename); const char *filename);
KLT_FeatureTable KLTReadFeatureTable( KLT_FeatureTable KLTReadFeatureTable(
KLT_FeatureTable ft, KLT_FeatureTable ft,
char *filename); const char *filename);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -96,7 +96,7 @@ void _KLTPrintSubFloatImage(
void _KLTWriteFloatImageToPGM( void _KLTWriteFloatImageToPGM(
_KLT_FloatImage img, _KLT_FloatImage img,
char *filename) const char *filename)
{ {
int npixs = img->ncols * img->nrows; int npixs = img->ncols * img->nrows;
float mmax = -999999.9f, mmin = 999999.9f; float mmax = -999999.9f, mmin = 999999.9f;
@ -137,7 +137,7 @@ void _KLTWriteFloatImageToPGM(
void _KLTWriteAbsFloatImageToPGM( void _KLTWriteAbsFloatImageToPGM(
_KLT_FloatImage img, _KLT_FloatImage img,
char *filename,float scale) const char *filename,float scale)
{ {
int npixs = img->ncols * img->nrows; int npixs = img->ncols * img->nrows;
float fact; float fact;

View File

@ -25,12 +25,12 @@ void _KLTPrintSubFloatImage(
void _KLTWriteFloatImageToPGM( void _KLTWriteFloatImageToPGM(
_KLT_FloatImage img, _KLT_FloatImage img,
char *filename); const char *filename);
/* for affine mapping */ /* for affine mapping */
void _KLTWriteAbsFloatImageToPGM( void _KLTWriteAbsFloatImageToPGM(
_KLT_FloatImage img, _KLT_FloatImage img,
char *filename,float scale); const char *filename,float scale);
#endif #endif

View File

@ -122,7 +122,7 @@ void ppmReadHeader(
*/ */
void pgmReadHeaderFile( void pgmReadHeaderFile(
char *fname, const char *fname,
int *magic, int *magic,
int *ncols, int *nrows, int *ncols, int *nrows,
int *maxval) int *maxval)
@ -148,7 +148,7 @@ void pgmReadHeaderFile(
*/ */
void ppmReadHeaderFile( void ppmReadHeaderFile(
char *fname, const char *fname,
int *magic, int *magic,
int *ncols, int *nrows, int *ncols, int *nrows,
int *maxval) int *maxval)
@ -218,7 +218,7 @@ unsigned char* pgmRead(
*/ */
unsigned char* pgmReadFile( unsigned char* pgmReadFile(
char *fname, const char *fname,
unsigned char *img, unsigned char *img,
int *ncols, int *nrows) int *ncols, int *nrows)
{ {
@ -247,7 +247,7 @@ unsigned char* pgmReadFile(
void pgmWrite( void pgmWrite(
FILE *fp, FILE *fp,
unsigned char *img, const unsigned char *img,
int ncols, int ncols,
int nrows) int nrows)
{ {
@ -271,8 +271,8 @@ void pgmWrite(
*/ */
void pgmWriteFile( void pgmWriteFile(
char *fname, const char *fname,
unsigned char *img, const unsigned char *img,
int ncols, int ncols,
int nrows) int nrows)
{ {
@ -298,9 +298,9 @@ void pgmWriteFile(
void ppmWrite( void ppmWrite(
FILE *fp, FILE *fp,
unsigned char *redimg, const unsigned char *redimg,
unsigned char *greenimg, const unsigned char *greenimg,
unsigned char *blueimg, const unsigned char *blueimg,
int ncols, int ncols,
int nrows) int nrows)
{ {
@ -328,10 +328,10 @@ void ppmWrite(
*/ */
void ppmWriteFileRGB( void ppmWriteFileRGB(
char *fname, const char *fname,
unsigned char *redimg, const unsigned char *redimg,
unsigned char *greenimg, const unsigned char *greenimg,
unsigned char *blueimg, const unsigned char *blueimg,
int ncols, int ncols,
int nrows) int nrows)
{ {

View File

@ -16,20 +16,20 @@
* used for reading from/writing to files * used for reading from/writing to files
*/ */
unsigned char* pgmReadFile( unsigned char* pgmReadFile(
char *fname, const char *fname,
unsigned char *img, unsigned char *img,
int *ncols, int *ncols,
int *nrows); int *nrows);
void pgmWriteFile( void pgmWriteFile(
char *fname, const char *fname,
unsigned char *img, const unsigned char *img,
int ncols, int ncols,
int nrows); int nrows);
void ppmWriteFileRGB( void ppmWriteFileRGB(
char *fname, const char *fname,
unsigned char *redimg, const unsigned char *redimg,
unsigned char *greenimg, const unsigned char *greenimg,
unsigned char *blueimg, const unsigned char *blueimg,
int ncols, int ncols,
int nrows); int nrows);
@ -42,14 +42,14 @@ unsigned char* pgmRead(
int *ncols, int *nrows); int *ncols, int *nrows);
void pgmWrite( void pgmWrite(
FILE *fp, FILE *fp,
unsigned char *img, const unsigned char *img,
int ncols, int ncols,
int nrows); int nrows);
void ppmWrite( void ppmWrite(
FILE *fp, FILE *fp,
unsigned char *redimg, const unsigned char *redimg,
unsigned char *greenimg, const unsigned char *greenimg,
unsigned char *blueimg, const unsigned char *blueimg,
int ncols, int ncols,
int nrows); int nrows);

View File

@ -40,7 +40,7 @@ void KLTWriteFeatureListToPPM(
KLT_PixelType *greyimg, KLT_PixelType *greyimg,
int ncols, int ncols,
int nrows, int nrows,
char *filename) const char *filename)
{ {
int nbytes = ncols * nrows * sizeof(char); int nbytes = ncols * nrows * sizeof(char);
uchar *redimg, *grnimg, *bluimg; uchar *redimg, *grnimg, *bluimg;
@ -94,8 +94,8 @@ void KLTWriteFeatureListToPPM(
static FILE* _printSetupTxt( static FILE* _printSetupTxt(
char *fname, /* Input: filename, or NULL for stderr */ const char *fname, /* Input: filename, or NULL for stderr */
char *fmt, /* Input: format (e.g., %5.1f or %3d) */ const char *fmt, /* Input: format (e.g., %5.1f or %3d) */
char *format, /* Output: format (e.g., (%5.1f,%5.1f)=%3d) */ char *format, /* Output: format (e.g., (%5.1f,%5.1f)=%3d) */
char *type) /* Output: either 'f' or 'd', based on input format */ char *type) /* Output: either 'f' or 'd', based on input format */
{ {
@ -131,7 +131,7 @@ static FILE* _printSetupTxt(
static FILE* _printSetupBin( static FILE* _printSetupBin(
char *fname) /* Input: filename */ const char *fname) /* Input: filename */
{ {
FILE *fp; FILE *fp;
if (fname == NULL) { if (fname == NULL) {
@ -169,8 +169,8 @@ static void _printInteger(
static KLT_BOOL _isCharInString( static KLT_BOOL _isCharInString(
char c, const char c,
char *str) const char *str)
{ {
int width = strlen(str); int width = strlen(str);
int i; int i;
@ -191,7 +191,7 @@ static KLT_BOOL _isCharInString(
*/ */
static int _findStringWidth( static int _findStringWidth(
char *str) const char *str)
{ {
int width = 0; int width = 0;
int add; int add;
@ -234,7 +234,7 @@ static int _findStringWidth(
static void _printHeader( static void _printHeader(
FILE *fp, FILE *fp,
char *format, const char *format,
structureType id, structureType id,
int nFrames, int nFrames,
int nFeatures) int nFeatures)
@ -290,8 +290,8 @@ static void _printHeader(
static void _printFeatureTxt( static void _printFeatureTxt(
FILE *fp, FILE *fp,
KLT_Feature feat, KLT_Feature feat,
char *format, const char *format,
char type) const char type)
{ {
assert(type == 'f' || type == 'd'); assert(type == 'f' || type == 'd');
@ -343,8 +343,8 @@ static void _printShutdown(
void KLTWriteFeatureList( void KLTWriteFeatureList(
KLT_FeatureList fl, KLT_FeatureList fl,
char *fname, const char *fname,
char *fmt) const char *fmt)
{ {
FILE *fp; FILE *fp;
char format[100]; char format[100];
@ -381,8 +381,8 @@ void KLTWriteFeatureList(
void KLTWriteFeatureHistory( void KLTWriteFeatureHistory(
KLT_FeatureHistory fh, KLT_FeatureHistory fh,
char *fname, const char *fname,
char *fmt) const char *fmt)
{ {
FILE *fp; FILE *fp;
char format[100]; char format[100];
@ -420,8 +420,8 @@ void KLTWriteFeatureHistory(
void KLTWriteFeatureTable( void KLTWriteFeatureTable(
KLT_FeatureTable ft, KLT_FeatureTable ft,
char *fname, const char *fname,
char *fmt) const char *fmt)
{ {
FILE *fp; FILE *fp;
char format[100]; char format[100];
@ -616,7 +616,7 @@ static void _readFeatureBin(
KLT_FeatureList KLTReadFeatureList( KLT_FeatureList KLTReadFeatureList(
KLT_FeatureList fl_in, KLT_FeatureList fl_in,
char *fname) const char *fname)
{ {
FILE *fp; FILE *fp;
KLT_FeatureList fl; KLT_FeatureList fl;
@ -679,7 +679,7 @@ KLT_FeatureList KLTReadFeatureList(
KLT_FeatureHistory KLTReadFeatureHistory( KLT_FeatureHistory KLTReadFeatureHistory(
KLT_FeatureHistory fh_in, KLT_FeatureHistory fh_in,
char *fname) const char *fname)
{ {
FILE *fp; FILE *fp;
KLT_FeatureHistory fh; KLT_FeatureHistory fh;
@ -741,7 +741,7 @@ KLT_FeatureHistory KLTReadFeatureHistory(
KLT_FeatureTable KLTReadFeatureTable( KLT_FeatureTable KLTReadFeatureTable(
KLT_FeatureTable ft_in, KLT_FeatureTable ft_in,
char *fname) const char *fname)
{ {
FILE *fp; FILE *fp;
KLT_FeatureTable ft; KLT_FeatureTable ft;