Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

thd_forcemalloc.c File Reference

#include "mrilib.h"
#include "thd.h"

Go to the source code of this file.


Functions

void THD_force_malloc_type (THD_datablock *blk, int mem_type)

Variables

int native_order = -1
int no_mmap = -1

Function Documentation

void THD_force_malloc_type THD_datablock   blk,
int    mem_type
 

Definition at line 13 of file thd_forcemalloc.c.

References AFNI_yesenv(), THD_diskptr::brick_name, THD_diskptr::byte_order, COMPRESS_filecode(), DATABLOCK_MEM_ANY, DATABLOCK_MEM_MALLOC, DATABLOCK_MEM_MMAP, DBLK_LOCKED, DBLK_mmapfix, THD_datablock::diskptr, ISVALID_DATABLOCK, THD_datablock::malloc_type, MMAP_THRESHOLD, mri_short_order(), native_order, no_mmap, THD_purge_datablock(), and THD_datablock::total_bytes.

Referenced by B2F_read_opts(), BUCK_read_opts(), EDIT_dset_items(), EDIT_one_dataset(), main(), PLUTO_add_dset(), RT_tell_afni_one(), TCAT_read_opts(), and ZCAT_read_opts().

00014 {
00015    int new_type ;
00016 
00017    no_mmap = AFNI_yesenv("AFNI_NOMMAP") ;
00018 
00019    if( native_order < 0 ) native_order = mri_short_order() ;
00020 
00021    /*-- sanity checks --*/
00022 
00023    if( ! ISVALID_DATABLOCK(blk) ) return ;
00024 
00025    if( mem_type == DATABLOCK_MEM_ANY ){  /* 14 Oct 1996 */
00026 #if MMAP_THRESHOLD > 0
00027       new_type = (blk->total_bytes > MMAP_THRESHOLD)
00028                     ? DATABLOCK_MEM_MMAP : DATABLOCK_MEM_MALLOC ;
00029 #else
00030       new_type = DATABLOCK_MEM_MALLOC ;
00031 #endif
00032 
00033    } else {
00034       new_type = mem_type ;
00035    }
00036 
00037    if( COMPRESS_filecode(blk->diskptr->brick_name) >= 0 && new_type == DATABLOCK_MEM_MMAP )
00038       new_type = DATABLOCK_MEM_MALLOC ;
00039 
00040    /* 25 April 1998: byte order issues */
00041 
00042    if( blk->diskptr->byte_order <= 0 )
00043       blk->diskptr->byte_order = native_order ;
00044    else if( blk->diskptr->byte_order != native_order && new_type == DATABLOCK_MEM_MMAP )
00045       new_type = DATABLOCK_MEM_MALLOC ;
00046 
00047    if( no_mmap && new_type == DATABLOCK_MEM_MMAP )
00048       new_type = DATABLOCK_MEM_MALLOC ;
00049 
00050    if( DBLK_LOCKED(blk) )                /* 22 Mar 2001 */
00051       new_type = DATABLOCK_MEM_MALLOC ;
00052 
00053    if( blk->malloc_type == new_type ) return ;
00054    (void) THD_purge_datablock( blk , blk->malloc_type ) ;
00055    blk->malloc_type = new_type ;
00056 
00057    DBLK_mmapfix(blk) ;  /* 28 Mar 2005 */
00058    return ;
00059 }

Variable Documentation

int native_order = -1 [static]
 

Definition at line 10 of file thd_forcemalloc.c.

Referenced by THD_force_malloc_type().

int no_mmap = -1 [static]
 

Definition at line 11 of file thd_forcemalloc.c.

Referenced by THD_force_malloc_type().

 

Powered by Plone

This site conforms to the following standards: