diff --git a/trick_source/sim_services/MemoryManager/src/MemoryManager_ref_assignment.cpp b/trick_source/sim_services/MemoryManager/src/MemoryManager_ref_assignment.cpp index cda7cb55..bc9cd5bf 100644 --- a/trick_source/sim_services/MemoryManager/src/MemoryManager_ref_assignment.cpp +++ b/trick_source/sim_services/MemoryManager/src/MemoryManager_ref_assignment.cpp @@ -265,12 +265,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in } else if ( remaining_dimensions > 0 ) { - int size_of_curr_dim; - - size_of_curr_dim = attr->index[curr_dim].size ; - assign_addr = (char*)base_addr + offset * sizeof(void*); + int size_of_curr_dim = attr->index[curr_dim].size ; if ( size_of_curr_dim == 0) { // the remaining dimensions are pointer dimensions. + + assign_addr = (char*)base_addr + offset * sizeof(void*); + if (v_tree && v_tree->v_data) { if ((remaining_dimensions == 1) && (v_tree->v_data->type == TRICK_STRING)) { @@ -297,6 +297,8 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in (v_tree->v_data) ) { + assign_addr = (char*)base_addr + offset * size_of_curr_dim * sizeof(char); + if ((v_tree->v_data->type == TRICK_STRING) && (v_tree->v_data->value.cp != NULL)) { @@ -310,10 +312,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in } else { *(char*)assign_addr = '\0'; } - + } else if ( (attr->type == TRICK_WCHAR) && (remaining_dimensions == 1)) { + assign_addr = (char*)base_addr + offset * size_of_curr_dim * sizeof(wchar_t); + if ((v_tree) && (v_tree->v_data->type == TRICK_WSTRING) && (v_tree->v_data->value.wcp != NULL)) { @@ -345,7 +349,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in } else { *(wchar_t*)assign_addr = (wchar_t) NULL; } - + } else { int ii; V_TREE* curr_vt_node; @@ -353,7 +357,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in curr_vt_node = v_tree->down; } else { curr_vt_node = NULL; - } + } for (ii=0; ii < size_of_curr_dim; ii++) { int ret; diff --git a/trick_source/sim_services/MemoryManager/test/MM_read_checkpoint.cc b/trick_source/sim_services/MemoryManager/test/MM_read_checkpoint.cc index 53b88779..916a450a 100644 --- a/trick_source/sim_services/MemoryManager/test/MM_read_checkpoint.cc +++ b/trick_source/sim_services/MemoryManager/test/MM_read_checkpoint.cc @@ -4,6 +4,7 @@ #include "MM_user_defined_types.hh" #include "MM_test.hh" #include +#include /* @@ -235,3 +236,34 @@ TEST_F(MM_read_checkpoint, bool_test) { EXPECT_EQ( T_flag, true); EXPECT_EQ( F_flag, false); } + + + +TEST_F(MM_read_checkpoint, 2D_char_array) { + + UDT7 *udt7_p = (UDT7*)memmgr->declare_var("UDT7 udt7"); + + memmgr->set_debug_level(1); + memmgr->read_checkpoint_from_string( + "udt7.A = {" + "\"A00\",\"A01\",\"A02\",\"A03\",\"A04\",\"A05\",\"A06\",\"A07\"," + "\"A08\",\"A09\",\"A10\",\"A11\",\"A12\",\"A13\",\"A14\",\"A15\"," + "\"A16\",\"A17\",\"A18\",\"A19\",\"A20\",\"A21\",\"A22\",\"A23\"," + "\"A24\",\"A25\",\"A26\",\"A27\",\"A28\",\"A29\",\"A30\",\"A31\"};" + ); + + for (int ii=0; ii<32; ii++) { + std::stringstream ss; + ss << "A" ; + ss << std::setfill('0') << std::setw(2) ; + ss << ii ; + std::cout << ss.str() << std::endl; + int result = ss.str().compare( &udt7_p->A[ii][0] ); + + EXPECT_EQ(result, 0); + } + + + + +} diff --git a/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh b/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh index ed67e86b..f64c4f50 100644 --- a/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh +++ b/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh @@ -87,3 +87,9 @@ class UDT4 : public UDT3 { double XX; }; +class UDT7 { + public: + char A[32][4]; + char B[32][4]; +}; +