This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Variable not getting memory allocated

Hello members,

I have following code built successfully with MDK-ARM v4.7.

void FS_update_version_info (void)
{ char *file_src, *file_dest;

strcpy(&file_src[0], folder_path_config);
strcat(file_src, file_path_config);
strcpy(&file_dest[0], folder_path_config);
strcat(file_dest, file_path_config_temp);
}

When I debug the code, I found that variable "file_dest" is not getting memory allocated, hence it is not getting updated with the assigned value. I tried increasing stack/heap values from startup file. Also tried increasing IRAM1 option from Target->Options dialog but no use. Any idea what is the reason for this? I am using RL-TCP, RL-USB and RL-FlashFS libraries in my code.

Thanks in advance for any help.

Mike.

Parents
  • void FS_update_version_info(void)
    {
      char file_src[64], file_dest[64]; // Allocate some memory (enough) for this stuff
    
      strcpy(file_src, folder_path_config);
      strcat(file_src, file_path_config);
      strcpy(file_dest, folder_path_config);
      strcat(file_dest, file_path_config_temp);
    
      // when exits here file_src and file_dest lose scope and are destroyed
    }
    

    Some pretty basic C concepts at work here.

Reply
  • void FS_update_version_info(void)
    {
      char file_src[64], file_dest[64]; // Allocate some memory (enough) for this stuff
    
      strcpy(file_src, folder_path_config);
      strcat(file_src, file_path_config);
      strcpy(file_dest, folder_path_config);
      strcat(file_dest, file_path_config_temp);
    
      // when exits here file_src and file_dest lose scope and are destroyed
    }
    

    Some pretty basic C concepts at work here.

Children