vPortFree(ptr) and ptr new value

Hi,
I’m using FreeRTOS with CMSIS v1 on STM32F469 uC. Inside project there’s used heap_4.c
I’d like to know how vPortFree really works.

Sample code:

uint8_t* ptr;     //declaration of pointer
    ptr = (uint8_t*)pvPortMalloc(sizeof(uint8_t));   //assing address on heap - 0x20007e58
if(ptr == NULL)
	return -1;                   //if my pointer is not assigned return from function
*ptr = 0xFF;          //assign value to reserved address

vPortFree((void*)ptr);    //free memory, so ptr should be NULL, but it's still  0x20007e58

Am I right with understanding vPortFree? Should it assing NULL to the ptr?

1 Like

It can’t be NULLed by vPortFree with its API matching standard free.
You could add your own wrapper my_free( void** ptr ) to be able to NULL the given ptr.

2 Likes

Thanks for answer. I’ll consider using wrapper as you suggest.
Because of not NULLing pointer I was scared, that vPortFree() doesn’t really free this declared memory. But I already finished some debugging and memory mapping with multiple pointers of different type and spotted no sign of heap overflowing, so I suppose everything works fine.