Mapped Files
[libbu (utility functions)]

Collaboration diagram for Mapped Files:


Files

file  mappedfile.c
 Routines for sharing large read-only data files.

Functions

bu_mapped_filebu_open_mapped_file (const char *name, const char *appl)
void bu_close_mapped_file (struct bu_mapped_file *mp)
void bu_pr_mapped_file (const char *title, const struct bu_mapped_file *mp)
void bu_free_mapped_files (int verbose)
bu_mapped_filebu_open_mapped_file_with_path (char *const *path, const char *name, const char *appl)

Detailed Description

B U _ M A P P E D _ F I L E

Function Documentation

struct bu_mapped_file * bu_open_mapped_file const char *  name,
const char *  appl
 

B U _ O P E N _ M A P P E D _ F I L E

If the file can not be opened, as descriptive an error message as possible will be printed, to simplify code handling in the caller.

Mapped files are always opened read-only.

If the system does not support mapped files, the data is read into memory.

Definition at line 104 of file mappedfile.c.

References bu_mapped_file::appl, BU_CK_MAPPED_FILE, bu_debug, BU_DEBUG_DB, BU_DEBUG_MAPPED_FILE, bu_free(), BU_GETSTRUCT, BU_LIST_APPEND, BU_LIST_FOR, BU_LIST_INIT, BU_LIST_UNINITIALIZED, bu_log(), bu_malloc(), BU_MAPPED_FILE_MAGIC, bu_pr_mapped_file(), BU_SEM_MAPPEDFILE, BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), bu_strdup, bu_mapped_file::buf, bu_mapped_file::buflen, fp, bu_mapped_file::is_mapped, bu_mapped_file::l, bu_list::magic, bu_mapped_file::modtime, bu_mapped_file::name, NULL, perror(), sbrk(), bu_mapped_file::uses, and void().

Referenced by bu_open_mapped_file_with_path(), db_open(), rt_hf_import(), and rt_mk_binunif().

Here is the call graph for this function:

void bu_close_mapped_file struct bu_mapped_file mp  ) 
 

B U _ C L O S E _ M A P P E D _ F I L E

Release a use of a mapped file. Because it may be re-used shortly, e.g. by the next frame of an animation, don't release the memory even on final close, so that it's available when next needed. Call bu_free_mapped_files() after final close to reclaim space. But only do that if you're SURE that ALL these files will never again need to be mapped by this process. Such as when running multi-frame animations.

Definition at line 336 of file mappedfile.c.

References BU_CK_MAPPED_FILE, bu_debug, BU_DEBUG_MAPPED_FILE, bu_log(), bu_pr_mapped_file(), BU_SEM_MAPPEDFILE, bu_semaphore_acquire(), bu_semaphore_release(), and bu_mapped_file::uses.

Referenced by db_close(), rt_dsp_free(), rt_dsp_ifree(), rt_ebm_free(), rt_ebm_ifree(), rt_hf_free(), rt_hf_ifree(), and rt_mk_binunif().

Here is the call graph for this function:

void bu_pr_mapped_file const char *  title,
const struct bu_mapped_file mp
 

B U _ P R _ M A P P E D _ F I L E

Definition at line 357 of file mappedfile.c.

References BU_CK_MAPPED_FILE, bu_log(), and bu_mapped_file::name.

Referenced by bu_close_mapped_file(), bu_free_mapped_files(), and bu_open_mapped_file().

Here is the call graph for this function:

void bu_free_mapped_files int  verbose  ) 
 

B U _ F R E E _ M A P P E D _ F I L E S

Release storage being used by mapped files with no remaining users. This entire routine runs inside a critical section, for parallel protection. Only call this routine if you're SURE that ALL these files will never again need to be mapped by this process. Such as when running multi-frame animations.

Definition at line 377 of file mappedfile.c.

References bu_mapped_file::apbuf, bu_mapped_file::appl, BU_CK_MAPPED_FILE, bu_debug, BU_DEBUG_MAPPED_FILE, bu_free(), BU_LIST_DEQUEUE, BU_LIST_FIRST, BU_LIST_NEXT, BU_LIST_NOT_HEAD, bu_log(), bu_pr_mapped_file(), BU_SEM_MAPPEDFILE, BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), bu_mapped_file::buf, bu_mapped_file::buflen, bu_mapped_file::is_mapped, bu_mapped_file::l, bu_mapped_file::name, NULL, perror(), and bu_mapped_file::uses.

Referenced by db_close().

Here is the call graph for this function:

struct bu_mapped_file * bu_open_mapped_file_with_path char *const *  path,
const char *  name,
const char *  appl
 

B U _ O P E N _ M A P P E D _ F I L E _ W I T H _ P A T H

A wrapper for bu_open_mapped_file() which uses a search path to locate the file. The search path is specified as a normal C argv array, terminated by a null string pointer. If the file name begins with a slash ('/') the path is not used.

Definition at line 436 of file mappedfile.c.

References BU_ASSERT_PTR, bu_open_mapped_file(), bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_putc(), bu_vls_strcat(), bu_vls_strcpy(), and NULL.

Referenced by rt_ebm_import(), and rt_ebm_import5().

Here is the call graph for this function:


Generated on Mon Sep 18 01:25:20 2006 for BRL-CAD by  doxygen 1.4.6