Fix types

This commit is contained in:
Clement Jamin 2016-06-15 17:51:23 +02:00
parent dfc9a2f04b
commit 3b61a9d611
3 changed files with 23 additions and 23 deletions

View File

@ -48,7 +48,7 @@ PTRIMAGE_FORMAT createGisFormat() {
CGAL_INLINE_FUNCTION
int writeGis( char *name, _image* im) {
char *outputName;
int res;
std::size_t res;
std::size_t length, extLength = 0;
length=strlen(name);
@ -142,8 +142,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = static_cast<int>(ImageIO_write( im, str, strlen( str )));
if ( res <= 0 ) {
res = ImageIO_write( im, str, strlen( str ));
if ( res < strlen(str) ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
return( -3 );
@ -161,8 +161,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = static_cast<int>(ImageIO_write( im, str, strlen( str )));
if ( res <= 0 ) {
res = ImageIO_write( im, str, strlen( str ));
if ( res < strlen(str) ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
return( -3 );
@ -188,8 +188,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = static_cast<int>(ImageIO_write(im, str, strlen(str)));
if ( res <= 0 ) {
res = ImageIO_write( im, str, strlen( str ));
if ( res < strlen(str) ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
return( -3 );
@ -207,8 +207,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = static_cast<int>(ImageIO_write(im, str, strlen(str)));
if ( res <= 0 ) {
res = ImageIO_write( im, str, strlen( str ));
if ( res < strlen(str) ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
return( -3 );
@ -222,13 +222,14 @@ int writeGis( char *name, _image* im) {
} /* end of switch( im->wordKind ) */
ImageIO_free( str );
if (outputName != NULL) ImageIO_free(outputName);
return static_cast<int>(res);
}
else {
res = _writeInrimageData(im);
bool ret = _writeInrimageData(im);
if (outputName != NULL) ImageIO_free(outputName);
return (ret ? 1 : -1);
}
if ( outputName != NULL ) ImageIO_free( outputName );
return res;
}
CGAL_INLINE_FUNCTION

View File

@ -36,7 +36,7 @@ int _writeInrimageHeader(const _image *im,
/** Writes the given image body in an already opened file.
@param im image descriptor */
int _writeInrimageData(const _image *im);
bool _writeInrimageData(const _image *im);
/** read header from an opened inrimage file
@param im opened inrmage descriptor */

View File

@ -194,7 +194,7 @@ int _writeInrimageHeader(const _image *im, ENDIANNESS end) {
/* Writes the given image body in an already opened file.*/
CGAL_INLINE_FUNCTION
int _writeInrimageData(const _image *im) {
bool _writeInrimageData(const _image *im) {
std::size_t size, nbv, nwrt, i, v;
unsigned char **vp;
@ -204,8 +204,8 @@ int _writeInrimageData(const _image *im) {
if(im->vectMode != VM_NON_INTERLACED) {
size = im->xdim * im->ydim * im->zdim * im->vdim * im->wdim;
nwrt = ImageIO_write(im, im->data, size);
if(nwrt != size) return -1;
else return 1;
if(nwrt != size) return false;
else return true;
}
/* non interlaced vectors: interlace for saving */
@ -218,14 +218,14 @@ int _writeInrimageData(const _image *im) {
for(i = 0; i < nbv; i++)
for(v = 0; v < im->vdim; v++) {
if(ImageIO_write(im, (const void *) vp[v], im->wdim) != im->wdim)
return -1;
return false;
vp[v] += im->wdim;
}
ImageIO_free(vp);
return 1;
return true;
}
}
else return -1;
else return false;
}
@ -486,14 +486,13 @@ int writeInrimage(char *name,_image *im) {
return( res );
}
res = _writeInrimageData( im );
if (res < 0) {
if (!_writeInrimageData(im)) {
fprintf(stderr, "writeInrimage: error: unable to write data of \'%s\'\n",
name);
ImageIO_close( im );
im->fd = NULL;
im->openMode = OM_CLOSE;
return( res );
return -1;
}
ImageIO_close( im );