Doxygen Source Code Documentation
edt_fullcopy.c File Reference
#include "mrilib.h"Go to the source code of this file.
Functions | |
| THD_3dim_dataset * | EDIT_full_copy (THD_3dim_dataset *dset, char *new_prefix) |
Function Documentation
|
||||||||||||
|
Definition at line 13 of file edt_fullcopy.c. References ADN_label1, ADN_none, ADN_prefix, THD_3dim_dataset::dblk, DSET_BRICK_ARRAY, DSET_BRICK_BYTES, DSET_BRICK_TYPE, DSET_NVALS, EDIT_dset_items(), EDIT_empty_copy(), EDIT_substitute_brick(), ENTRY, ISVALID_3DIM_DATASET, malloc, RETURN, THD_delete_3dim_dataset(), and THD_load_datablock(). Referenced by main(), PLUTO_copy_dset(), process_dataset(), and THD_zeropad().
00014 {
00015 THD_3dim_dataset *new_dset ;
00016 int ival , ityp , nbytes , nvals ;
00017 void *new_brick , *old_brick ;
00018
00019 ENTRY("EDIT_full_copy") ;
00020
00021 /*-- sanity check --*/
00022
00023 if( ! ISVALID_3DIM_DATASET(dset) ) RETURN(NULL) ;
00024
00025 /*-- make the empty copy --*/
00026
00027 new_dset = EDIT_empty_copy( dset ) ; /* copy is set to MALLOC memory */
00028
00029 /*-- change its name? --*/
00030
00031 if( new_prefix != NULL )
00032 EDIT_dset_items( new_dset ,
00033 ADN_prefix , new_prefix ,
00034 ADN_label1 , new_prefix ,
00035 ADN_none ) ;
00036
00037 /*-- make brick(s) for this dataset --*/
00038
00039 THD_load_datablock( dset->dblk ) ; /* make sure old one is in memory */
00040
00041 nvals = DSET_NVALS(dset) ;
00042
00043 for( ival=0 ; ival < nvals ; ival++ ){
00044 ityp = DSET_BRICK_TYPE(new_dset,ival) ; /* type of data */
00045 nbytes = DSET_BRICK_BYTES(new_dset,ival) ; /* how much data */
00046 new_brick = malloc( nbytes ) ; /* make room */
00047
00048 if( new_brick == NULL ){
00049 THD_delete_3dim_dataset( new_dset , False ) ;
00050 RETURN(NULL) ;
00051 }
00052
00053 EDIT_substitute_brick( new_dset , ival , ityp , new_brick ) ;
00054
00055 /*-- copy data from old brick to new brick --*/
00056
00057 old_brick = DSET_BRICK_ARRAY(dset,ival) ;
00058
00059 if( old_brick == NULL ){
00060 THD_delete_3dim_dataset( new_dset , False ) ;
00061 RETURN(NULL) ;
00062 }
00063
00064 memcpy( new_brick , old_brick , nbytes ) ;
00065 }
00066
00067 RETURN( new_dset );
00068 }
|