This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

malloc() on tm4c123gh6pm launchpad not working CCSv6

I am trying to create a cstring dynamically to hold incoming characters being read in from UART. The malloc() function keeps returning an error (NULL). My UART is writing and reading perfectly. I have been able to store it in a non-dynamic cstring (char str[]), but I need it dynamic. This is the relevant code that I have:

//===================================================================================

void UART3IntHandler(void) {
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART3_BASE, true); // Get the interrrupt status.
UARTIntClear(UART3_BASE, ui32Status); // Clear the asserted interrupts.

char *strDATA; //the cstring I wish to make dynamic
strDATA = (char *)malloc( sizeof(char) * 1 );
if(strDATA == NULL) { return; } //check for malloc error (which is occuring)

*strDATA = UARTCharGet(UART3_BASE); // strDATA[0] = first character on UART buffer
UARTCharPut(UART1_BASE, *strDATA); // test to see what is actually being stored in *strData

i = 1; // this is so that the next character is read into strDATA[1]
while(UARTCharsAvail(UART3_BASE)) { //while incoming data buffer is not empty
strDATA = (char *) realloc(strDATA, i+1); // make space for new character
if(strDATA == NULL) { return; } //check for malloc error
strDATA[i] = UARTCharGet(UART3_BASE); // strDATA[i] = next character on UART buffer
i++; // iterate to next cell to store the next incoming char
}

for(i=0; i < sizeof(strDATA); i++) { // this is to test that the incoming data was stored correctly.
UARTCharPut(UART1_BASE, strDATA[i]); // echo test (make UART1 echo UART3)
}
}

//====================================================================================