I have been trying to assign a dynamic array of pointers file pointers in SystemC by referring to a system Verilog code as shown below can any please inform me if I did it correctly,because I am not sure if I allocated memory correctly in system C code thank you.
Below is System Verilog code
class start;
int fps[];
fps = new[configuration.m_num_rd_cfg_files];
for (int i = 0; i < configuration.m_num_rd_cfg_files; i++) begin
int fp;
if (configuration.m_rd_cfg_files[i].m_check != CHECK_DUMP) continue;
fp = $fopen(configuration.m_rd_cfg_files[i].m_filename,"w");
if (fp== 0)
`uvm_error(get_type_name(),"failed to open file")
else
fps[i] = fp;
end
class end
Below is SystemC code which I translated from above SV code
class start
FILE **fps
fps = (FILE**)calloc(configuration->m_num_cfg_files, sizeof(FILE*));
for (int i = 0; i < configuration->m_num_rd_cfg_files; i++) {
FILE* fp;
if (configuration->m_rd_cfg_files[i].m_check != cfg_file_check_e::CHECK_DUMP) continue;
fp = fopen(configuration->m_rd_cfg_files[i].m_filename.c_str(),"w");
if (fp== 0)
{
UVM_ERROR(msg_id, ("failed to open file " ));
}
else
{
fps[i] = fp;
}
}
class end