Mercurial > hg > minc-tools
changeset 621:e38841811435
check_in_all
author | david <david> |
---|---|
date | Mon, 10 Oct 1994 20:33:01 +0000 |
parents | 1f70b4660f05 |
children | 8bbb7f863072 |
files | volume_io/Include/volume_io.h volume_io/Prog_utils/alloc_check.c volume_io/Testing/test_slice.c volume_io/Volumes/volumes.c |
diffstat | 4 files changed, 64 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/volume_io/Include/volume_io.h +++ b/volume_io/Include/volume_io.h @@ -24,6 +24,6 @@ #include <geometry.h> #include <volume.h> #include <transforms.h> -#include <volume_io_prototypes.h> +#include <vol_io_prototypes.h> #endif
--- a/volume_io/Prog_utils/alloc_check.c +++ b/volume_io/Prog_utils/alloc_check.c @@ -360,6 +360,26 @@ #endif /* ----------------------------- MNI Header ----------------------------------- +@NAME : memory_still_alloced +@INPUT : alloc_list +@OUTPUT : +@RETURNS : TRUE or FALSE +@DESCRIPTION: Decides if any memory is still alloced, thus checking for + memory leaks. +@METHOD : +@GLOBALS : +@CALLS : +@CREATED : David MacDonald +@MODIFIED : +---------------------------------------------------------------------------- */ + +private BOOLEAN memory_still_alloced( + alloc_struct *alloc_list ) +{ + return( alloc_list->header->forward[0] != (skip_entry *) NULL ); +} + +/* ----------------------------- MNI Header ----------------------------------- @NAME : output_alloc_list @INPUT : file : alloc_list @@ -807,21 +827,33 @@ { check_initialized_alloc_list( &alloc_list ); - if( filename != (char *) 0 && filename[0] != (char) 0 ) - file = fopen( filename, "w" ); - else - file = stdout; - - if( file != (FILE *) 0 ) + if( memory_still_alloced( &alloc_list ) ) { - get_date( date_str ); - - (void) fprintf( file, "Alloc table at %s\n", date_str ); + print( "\n" ); + print( "\n" ); + print( "A memory leak was found in this program.\n" ); + if( filename != NULL ) + print( "A description has been recorded in the file %s.\n", + filename ); + print( "Please report this file to the author of the program.\n" ); + print( "\n" ); - output_alloc_list( file, &alloc_list ); + if( filename != (char *) 0 && filename[0] != (char) 0 ) + file = fopen( filename, "w" ); + else + file = stdout; - if( file != stdout ) - (void) fclose( file ); + if( file != (FILE *) 0 ) + { + get_date( date_str ); + + (void) fprintf( file, "Alloc table at %s\n", date_str ); + + output_alloc_list( file, &alloc_list ); + + if( file != stdout ) + (void) fclose( file ); + } } } }
--- a/volume_io/Testing/test_slice.c +++ b/volume_io/Testing/test_slice.c @@ -1,4 +1,4 @@ -#include <def_mni.h> +#include <mni.h> private void check( Volume volume,
--- a/volume_io/Volumes/volumes.c +++ b/volume_io/Volumes/volumes.c @@ -1114,7 +1114,7 @@ } } -public Volume copy_volume_definition( +public Volume copy_volume_definition_no_alloc( Volume volume, nc_type nc_data_type, BOOLEAN signed_flag, @@ -1140,7 +1140,6 @@ volume->dimension_names, nc_data_type, signed_flag, voxel_min, voxel_max ); set_volume_sizes( copy, sizes ); - alloc_volume_data( copy ); for_less( c, 0, N_DIMENSIONS ) copy->spatial_axes[c] = volume->spatial_axes[c]; @@ -1161,3 +1160,20 @@ return( copy ); } + +public Volume copy_volume_definition( + Volume volume, + nc_type nc_data_type, + BOOLEAN signed_flag, + Real voxel_min, + Real voxel_max ) +{ + Volume copy; + + copy = copy_volume_definition_no_alloc( volume, + nc_data_type, signed_flag, + voxel_min, voxel_max ); + alloc_volume_data( copy ); + + return( copy ); +}