Updated wolfSSL sub-module reference. Added implementation of realloc for FreeRTOS.

pull/2/head
David Garske 2018-05-14 11:00:10 -07:00
parent 05a5b70e2c
commit b4039f89fc
4 changed files with 58 additions and 1 deletions

View File

@ -6,6 +6,9 @@
/* Use the FreeRTOS Heap and TCP API's */
#define FREERTOS_TCP
/* Realloc for Heap */
#define XREALLOC pvPortRealloc
/* For Windows Simulator only */
#define FREERTOS_TCP_WINSIM

View File

@ -308,6 +308,33 @@ BlockLink_t *pxLink;
}
/*-----------------------------------------------------------*/
void *pvPortRealloc( void *pv, size_t xWantedSize )
{
void *pvReturn = NULL;
if(pv)
{
BlockLink_t *pxLink = (BlockLink_t *)((char*)pv - xHeapStructSize);
if(pxLink->xBlockSize & xBlockAllocatedBit)
{
uint32_t blockSize = (pxLink->xBlockSize & ~xBlockAllocatedBit);
blockSize -= xHeapStructSize;
pvReturn = pvPortMalloc(xWantedSize);
if(pvReturn)
{
memcpy(pvReturn, pv, blockSize);
vPortFree(pv);
}
}
}
else {
pvReturn = pvPortMalloc(xWantedSize);
}
return pvReturn;
}
/*-----------------------------------------------------------*/
size_t xPortGetFreeHeapSize( void )
{
return xFreeBytesRemaining;

View File

@ -317,6 +317,33 @@ BlockLink_t *pxLink;
}
/*-----------------------------------------------------------*/
void *pvPortRealloc( void *pv, size_t xWantedSize )
{
void *pvReturn = NULL;
if(pv)
{
BlockLink_t *pxLink = (BlockLink_t *)((char*)pv - xHeapStructSize);
if(pxLink->xBlockSize & xBlockAllocatedBit)
{
uint32_t blockSize = (pxLink->xBlockSize & ~xBlockAllocatedBit);
blockSize -= xHeapStructSize;
pvReturn = pvPortMalloc(xWantedSize);
if(pvReturn)
{
memcpy(pvReturn, pv, blockSize);
vPortFree(pv);
}
}
}
else {
pvReturn = pvPortMalloc(xWantedSize);
}
return pvReturn;
}
/*-----------------------------------------------------------*/
size_t xPortGetFreeHeapSize( void )
{
return xFreeBytesRemaining;

@ -1 +1 @@
Subproject commit 85b51b2b6e2f58b1afa5eb97ce5d03bd4ef6a16a
Subproject commit af9507391a0b2d9bebb144c80b2071f856ba9caa