Skip to content

Commit

Permalink
Keep old implementation of realloc for CC3220
Browse files Browse the repository at this point in the history
  • Loading branch information
adabreuti committed Apr 19, 2024
1 parent b570192 commit 92cf267
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/platform/cc13xx_26xx/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <reent.h>

#endif

extern void * pvPortRealloc(void * pv, size_t size);

/*
Expand Down Expand Up @@ -180,7 +181,7 @@ void ATTRIBUTE * calloc(size_t nmemb, size_t size)

return (retval);
}

#ifndef DeviceFamily_CC3220
/*
* ======== realloc ========
*/
Expand Down Expand Up @@ -234,6 +235,46 @@ void ATTRIBUTE * realloc(void * ptr, size_t size)
#endif
}

#else
/*
* ======== realloc ========
*/
void ATTRIBUTE * realloc(void * ptr, size_t size)
{
#if defined(TI_POSIX_FREERTOS_MEMORY_ENABLEADV)
void * retval;
Header * packet;
size_t oldSize;

if (ptr == NULL)
{
retval = malloc(size);
}
else if (size == 0)
{
errno = EINVAL;
retval = NULL;
}
else
{
packet = (Header *) ptr - 1;
retval = malloc(size);
if (retval != NULL)
{
oldSize = packet->header.size - sizeof(Header);
(void) memcpy(retval, ptr, (size < oldSize) ? size : oldSize);
free(ptr);
}
}

return (retval);
#else
/* Unsupported implementation */
return (NULL);
#endif
}
#endif

/*
* ======== free ========
*/
Expand Down

0 comments on commit 92cf267

Please sign in to comment.