mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 21:27:54 +00:00
This commit is contained in:
parent
b2aa92ae81
commit
9478b6a442
@ -819,19 +819,37 @@ namespace Trick {
|
||||
void io_src_delete_class(ALLOC_INFO * alloc_info);
|
||||
|
||||
/**
|
||||
FIXME: I NEED DOCUMENTATION!
|
||||
Clear the specified primitive or or array of primitives, beginning at the given base_address,
|
||||
described by attr, and whose specific array element is specified by curr_dim, and offset.
|
||||
*/
|
||||
void clear_rvalue( void* base_address, ATTRIBUTES* attr, int curr_dim, int offset);
|
||||
|
||||
/**
|
||||
FIXME: I NEED DOCUMENTATION!
|
||||
Clear the variable at the given address. That is, set the value(s) of the variable
|
||||
at the given address to 0, 0.0, NULL, false or "", as appropriate for the type.
|
||||
The difference between this function and clear_var(void* address) is that this
|
||||
doesn't contain calls to lock and unlock mm_mutex (which protects the alloc_info_map,
|
||||
and variable_map). This is meant to only be called from within other "critical-section"
|
||||
code that is surrounded by mutex lock and unlock.
|
||||
*/
|
||||
void clear_var_critical_section(void* address);
|
||||
|
||||
/**
|
||||
Clear the members of the class instance at <address>, and described by <attributes>.
|
||||
This too is only meant to be called from within other "critical-section" code that
|
||||
is surrounded by mutex lock and unlock.
|
||||
*/
|
||||
void clear_class( char *address, ATTRIBUTES * A);
|
||||
|
||||
/**
|
||||
FIXME: I NEED DOCUMENTATION!
|
||||
Clear the elements of the array at <address>, described by <attributes>, and whose .
|
||||
This too is only meant to be called from within other "critical-section" code that
|
||||
is surrounded by mutex lock and unlock.
|
||||
*/
|
||||
void clear_arrayed_class( char* address, ATTRIBUTES* A, int curr_dim, int offset);
|
||||
|
||||
/**
|
||||
FIXME: I NEED DOCUMENTATION!
|
||||
Write the given alloc_info data structure in a human readable to stdout.
|
||||
*/
|
||||
void debug_write_alloc_info( ALLOC_INFO *alloc_info);
|
||||
|
||||
@ -849,4 +867,3 @@ extern Trick::MemoryManager* trick_MM;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -220,12 +220,9 @@ void Trick::MemoryManager::clear_arrayed_class( char* address, ATTRIBUTES* A, in
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void Trick::MemoryManager::clear_var( void* address) {
|
||||
|
||||
void Trick::MemoryManager::clear_var_critical_section( void* address) {
|
||||
ATTRIBUTES* reference_attr;
|
||||
ALLOC_INFO* alloc_info;
|
||||
|
||||
pthread_mutex_lock(&mm_mutex);
|
||||
alloc_info = get_alloc_info_at( address);
|
||||
if (alloc_info != NULL) {
|
||||
reference_attr = make_reference_attr( alloc_info);
|
||||
@ -245,6 +242,12 @@ void Trick::MemoryManager::clear_var( void* address) {
|
||||
<< "because memory manager knows nothing about it." ;
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
// MEMBER FUNCTION
|
||||
void Trick::MemoryManager::clear_var( void* address) {
|
||||
pthread_mutex_lock(&mm_mutex);
|
||||
clear_var_critical_section(address);
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
|
||||
@ -259,9 +262,7 @@ void Trick::MemoryManager::clear_var( const char* name) {
|
||||
|
||||
if (pos != variable_map.end()) {
|
||||
alloc_info = pos->second;
|
||||
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
clear_var( alloc_info->start);
|
||||
clear_var_critical_section( alloc_info->start);
|
||||
} else {
|
||||
std::stringstream message;
|
||||
message << "Can't clear variable \"" << name
|
||||
@ -280,9 +281,7 @@ void Trick::MemoryManager::clear_all_vars() {
|
||||
pthread_mutex_lock(&mm_mutex);
|
||||
for (pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) {
|
||||
alloc_info = pos->second;
|
||||
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
clear_var( alloc_info->start);
|
||||
clear_var_critical_section( alloc_info->start);
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user