Using _RTCS_mem_pool for memory allocation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using _RTCS_mem_pool for memory allocation

Jump to solution
758 Views
jschepler
Contributor III

Hi,

I have MRAM attached to the flexbus that I would like to use for RTCS.  I have been running the task successfully by using the following:

_RTCS_mem_pool = _mem_create_pool(RTCS_mem_location, MRAM_POOL_SIZE);

Now, in my cgi function I would like to allocate memory inside the _RTCS_mem_pool to avoid using the internal RAM of the processor, so I do the following:

/* Read back the data sent from the webpage */
  req_len = (param->content_length) + 1;

  req_buffer = _mem_alloc_system_from(_RTCS_mem_pool, sizeof(char)*req_len);

  if(req_buffer != NULL)
  {
    read_len = HTTPSRV_cgi_read(param->ses_handle, req_buffer, req_len);
  }

I successfully point to a location in the _RTCS_mem_pool, but the call to HTTPSRV_cgi_read never returns.  Am I allowed to use the _RTCS_mem_pool for my own allocations?

Labels (1)
Tags (3)
1 Solution
632 Views
jschepler
Contributor III

Hi all,

I was able to successfully use the RTCS pool to allocate memory.  The reason HTTPSRV_cgi_read was failing was because I had an incorrect value for the last parameter.  It was stuck in a while loop internally waiting to read the number of byte I passed in parameter 3.  The reason I allocated +1 for memory was to store the '\0'.  

It now reads:

if(req_buffer != NULL)
{
  read_len = HTTPSRV_cgi_read(param->ses_handle, req_buffer, req_len - 1);
}‍‍‍‍

View solution in original post

1 Reply
633 Views
jschepler
Contributor III

Hi all,

I was able to successfully use the RTCS pool to allocate memory.  The reason HTTPSRV_cgi_read was failing was because I had an incorrect value for the last parameter.  It was stuck in a while loop internally waiting to read the number of byte I passed in parameter 3.  The reason I allocated +1 for memory was to store the '\0'.  

It now reads:

if(req_buffer != NULL)
{
  read_len = HTTPSRV_cgi_read(param->ses_handle, req_buffer, req_len - 1);
}‍‍‍‍