libsent/src/util/mybmalloc.c File Reference

Dynamic memory allocation per large block. More...

#include <sent/stddefs.h>

Include dependency graph for mybmalloc.c:

Go to the source code of this file.

Data Structures

struct  _linked_buffer
 Linked data structure to hold malloced areas. More...

Defines

#define MYBMALLOC_LINKED   1
 Use improved version that enables freeing.

Typedefs

typedef _linked_bufferLINKED_BUFFER
 Linked data structure to hold malloced areas.

Functions

void mybmalloc_set_param ()
void * mybmalloc (int size)
void mybmalloc_free (void)
char * mybstrdup (char *s)
void * mybmalloc2 (int size, BMALLOC_BASE **list)
char * mybstrdup2 (char *s, BMALLOC_BASE **list)
void mybfree2 (BMALLOC_BASE **list)

Variables

static boolean mybmalloc_initialized = FALSE
 TRUE if mybmalloc has already initialized.
static char * current = NULL
 Pointer to the current block.
static char * nowp = NULL
 Pointer to the current allocating point in the block.
static char * endp = NULL
 Pointer at the end of the current block.
static unsigned int blocksize
 Block size in bytes.
static int align
 Allocation alignment size in bytes.
static unsigned int align_mask
 Bit mask to compute the actual aligned memory size.
static LINKED_BUFFER first_linked_buffer = NULL
 Pointer to the first linked buffer.
static LINKED_BUFFER last_linked_buffer = NULL
 Pointer to the last linked buffer.


Detailed Description

Dynamic memory allocation per large block.

Author:
Akinobu LEE
Date:
Thu Feb 17 16:14:59 2005
This file defines functions that allocate memories per a certain big block instead of allocating for each required sizes. This function will improve the overhead of memory management operation, especially when an application requires huge number of small segments to be allocated. These functions are mainly used for allocating memory for acoustic models and language models.

Revision
1.5

Definition in file mybmalloc.c.


Function Documentation

void mybmalloc_set_param (  ) 

Set block size and memory alignment factor.

Definition at line 70 of file mybmalloc.c.

Referenced by mybmalloc(), mybmalloc2(), and system_bootup().

void* mybmalloc ( int  size  ) 

Malloc specified size and return the pointer.

Parameters:
size [in] required size in bytes
Returns:
pointer to the allocated area.

Definition at line 102 of file mybmalloc.c.

Referenced by mybstrdup().

void mybmalloc_free ( void   ) 

Free all the allocated area.

Definition at line 180 of file mybmalloc.c.

char* mybstrdup ( char *  s  ) 

String duplication using mybmalloc().

Parameters:
s [in] string to be duplicated
Returns:
pointer to the newly allocated string.

Definition at line 210 of file mybmalloc.c.

void* mybmalloc2 ( int  size,
BMALLOC_BASE **  list 
)

Another version of memory block allocation, used for tree lexicon.

Parameters:
size [in] memory size to be allocated
list [i/o] total memory management information (will be updated here)
Returns:
pointer to the newly allocated area.

Definition at line 228 of file mybmalloc.c.

Referenced by add_to_error(), add_wacc(), bt_relocate_rw(), dens_new(), dens_read(), get_back_trellis_end(), hmm_add_physical_to_logical(), hmm_add_pseudo_phones_sub(), htk_hmmdata_new(), htk_hmmdata_read(), make_hmm_basephone_list(), mybstrdup2(), outprob_cache_extend(), rd_data(), rd_dens(), rd_state(), rd_tmix(), rd_trans(), rd_var(), rdhmmlist(), rdn_str(), state_new(), state_read(), tmix_create_codebook_index(), tmix_read(), trans_new(), trans_read(), var_new(), var_read(), voca_load_htkdict_line(), wchmm_add_word(), and wchmm_duplicate_state().

char* mybstrdup2 ( char *  s,
BMALLOC_BASE **  list 
)

String duplication using mybmalloc2().

Parameters:
s [in] string to be duplicated
list [i/o] total memory management information pointer
Returns:
pointer to the newly allocated string.

Definition at line 265 of file mybmalloc.c.

Referenced by rdhmmdef(), rdhmmlist(), and tmix_read().

void mybfree2 ( BMALLOC_BASE **  list  ) 

Free all memories allocated by mybmalloc2()

Parameters:
list [i/o] total memory management information (will be cleaned here)

Definition at line 280 of file mybmalloc.c.

Referenced by bt_prepare(), hmminfo_free(), outprob_cache_free(), wchmm_free(), and word_info_free().


Generated on Tue Dec 26 12:55:10 2006 for Julian by  doxygen 1.5.0