Collaboration diagram for Memory:
![]() |
Files | |
file | malloc.c |
Parallel-protected debugging-enhanced wrapper around system malloc(). | |
Data Structures | |
struct | memdebug |
struct | memqdebug |
Defines | |
#define | bu_strdup(s) bu_strdupm(s, "bu_srtdup " BU_FLSTR) |
#define | MDB_MAGIC 0x12348969 |
#define | MEMDEBUG_NULL ((struct memdebug *)0) |
#define | MEMQDEBUG_NULL ((struct memqdebug *)0) |
Enumerations | |
enum | alloc_t { MALLOC, CALLOC } |
Functions | |
genptr_t | bu_malloc (unsigned int cnt, const char *str) |
void | bu_free (genptr_t ptr, const char *str) |
genptr_t | bu_realloc (genptr_t ptr, unsigned int cnt, const char *str) |
genptr_t | bu_calloc (unsigned int nelem, unsigned int elsize, const char *str) |
void | bu_prmem (const char *str) |
char * | bu_strdupm (const char *cp, const char *label) |
char * | bu_dirname (const char *cp) |
int | bu_malloc_len_roundup (int nbytes) |
void | bu_ck_malloc_ptr (genptr_t ptr, const char *str) |
int | bu_mem_barriercheck () |
HIDDEN void | bu_memdebug_add (char *ptr, unsigned int cnt, const char *str) |
HIDDEN struct memdebug * | bu_memdebug_check (register char *ptr, const char *str) |
genptr_t | bu_realloc (register genptr_t ptr, unsigned int cnt, const char *str) |
char * | bu_strdupm (register const char *cp, const char *label) |
int | bu_malloc_len_roundup (register int nbytes) |
void | bu_free_array (int argc, char *argv[], const char *str) |
Variables | |
long | bu_n_malloc |
long | bu_n_free |
long | bu_n_realloc |
int | bu_debug = 0 |
long | bu_n_malloc = 0 |
long | bu_n_free = 0 |
long | bu_n_realloc = 0 |
const char | bu_strdup_message [] = "bu_strdup string" |
const char | bu_vls_message [] |
|
|
Definition at line 92 of file malloc.c. Referenced by bu_ck_malloc_ptr(), bu_free(), bu_mem_barriercheck(), bu_memdebug_add(), bu_memdebug_check(), bu_prmem(), and bu_realloc(). |
|
Definition at line 102 of file malloc.c. Referenced by bu_free(), bu_memdebug_check(), and bu_realloc(). |
|
|
|
used by the memory allocation routines passed to bu_alloc by default to indicate whether allocated memory should be zero'd first. |
|
|
|
|
|
B U _ P R M E M Print map of memory currently in use. Definition at line 515 of file malloc.c. References bu_bomb(), bu_debug, bu_strdup_message, bu_vls_message, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, and memdebug::mdb_str. Referenced by bu_tcl_prmem(). Here is the call graph for this function: ![]() |
|
|
|
B U _ D I R N A M E Given a filesystem pathname, return a pointer to a dynamic string which is the parent directory of that file/directory.
/usr/dir/file /usr/dir Definition at line 641 of file malloc.c. References bu_free(), bu_strdup, and NULL. Referenced by db_open(). Here is the call graph for this function: ![]() |
|
Referenced by bu_tcl_malloc_len_roundup(), db_get_directory(), rt_ct_get(), rt_get_bitv(), and rt_get_seg(). |
|
B U _ C K _ M A L L O C _ P T R For a given pointer allocated by bu_malloc(), Check the magic number stored after the allocation area when BU_DEBUG_MEM_CHECK is set. This is the individual version of bu_mem_barriercheck(). returns if pointer good or BU_DEBUG_MEM_CHECK not set, bombs if memory is corrupted. Definition at line 736 of file malloc.c. References bu_bomb(), bu_debug, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, and NULL. Referenced by bu_tcl_ck_malloc_ptr(). Here is the call graph for this function: ![]() |
|
B U _ M E M _ B A R R I E R C H E C K Check *all* entries in the memory debug table for barrier word corruption. Intended to be called periodicly through an application during debugging. Has to run single-threaded, to prevent table mutation. This is the bulk version of bu_ck_malloc_ptr() Returns - -1 something is wrong 0 all is OK; Definition at line 796 of file malloc.c. References bu_bomb(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, and MDB_MAGIC. Referenced by Add_bot_face(), bu_tcl_mem_barriercheck(), curve_to_vlist(), dgo_E_cmd(), do_grid(), do_tri(), main(), rt_copy_sketch(), rt_extrude_xform(), rt_sketch_export(), rt_sketch_export5(), rt_sketch_ifree(), rt_sketch_import(), rt_sketch_import5(), and shoot_and_plot(). Here is the call graph for this function: ![]() |
|
B U _ M E M D E B U G _ A D D Add another entry to the memory debug table Definition at line 131 of file malloc.c. References BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, and top(). Here is the call graph for this function: ![]() |
|
B U _ M E M D E B U G _ C H E C K Check an entry against the memory debug table, based upon it's address. Definition at line 193 of file malloc.c. References bu_bomb(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, and MEMDEBUG_NULL. Referenced by bu_free(), and bu_realloc(). Here is the call graph for this function: ![]() |
|
B U _ R E A L L O C bu_malloc()/bu_free() compatible wrapper for realloc(). While the string 'str' is provided for the log messages, don't disturb the mdb_str value, so that this storage allocation can be tracked back to it's original creator. Definition at line 413 of file malloc.c. References BU_ASSERT, bu_bomb(), bu_debug, BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_MAGIC_SET, BU_LIST_MAGIC_WRONG, BU_LIST_NULL, bu_malloc(), bu_memdebug_check(), bu_n_realloc, BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memqdebug::m, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, MEMDEBUG_NULL, NULL, ptr, memqdebug::q, realloc(), and sbrk(). Here is the call graph for this function: ![]() |
|
B U _ S T R D U P Given a string, allocate enough memory to hold it using bu_malloc(), duplicate the strings, returns a pointer to the new string. Definition at line 603 of file malloc.c. References bu_debug, bu_malloc(), BU_SEM_SYSCALL, bu_semaphore_acquire(), and bu_semaphore_release(). Here is the call graph for this function: ![]() |
|
B U _ M A L L O C _ L E N _ R O U N D U P On systems with the CalTech malloc(), the amount of storage ACTUALLY ALLOCATED is the amount requested rounded UP to the nearest power of two. For structures which are acquired and released often, this works well, but for structures which will remain unchanged for the duration of the program, this wastes as much as 50% of the address space (and usually memory as well). Here, we round up a byte size to the nearest power of two, leaving off the malloc header, so as to ask for storage without wasting any. On systems with the traditional malloc(), this strategy will just consume the memory in somewhat larger chunks, but overall little unused memory will be consumed. |
|
b u _ f r e e _ a r r a y free up to argc elements of memory allocated to an array without free'ing the array itself. Definition at line 833 of file malloc.c. References bu_free(), and NULL. Here is the call graph for this function: ![]() |
|
|
|
|
|
Definition at line 90 of file malloc.c. Referenced by bu_realloc(). |
|
|
|
|
|
|
Definition at line 90 of file malloc.c. Referenced by bu_realloc(). |
|
Definition at line 113 of file malloc.c. Referenced by bu_prmem(). |
|
Definition at line 74 of file vls.c. Referenced by bu_prmem(). |