Skip to content

Commit 92cf267

Browse files
committed
Keep old implementation of realloc for CC3220
1 parent b570192 commit 92cf267

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/platform/cc13xx_26xx/memory.c

+42-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <reent.h>
7070

7171
#endif
72+
7273
extern void * pvPortRealloc(void * pv, size_t size);
7374

7475
/*
@@ -180,7 +181,7 @@ void ATTRIBUTE * calloc(size_t nmemb, size_t size)
180181

181182
return (retval);
182183
}
183-
184+
#ifndef DeviceFamily_CC3220
184185
/*
185186
* ======== realloc ========
186187
*/
@@ -234,6 +235,46 @@ void ATTRIBUTE * realloc(void * ptr, size_t size)
234235
#endif
235236
}
236237

238+
#else
239+
/*
240+
* ======== realloc ========
241+
*/
242+
void ATTRIBUTE * realloc(void * ptr, size_t size)
243+
{
244+
#if defined(TI_POSIX_FREERTOS_MEMORY_ENABLEADV)
245+
void * retval;
246+
Header * packet;
247+
size_t oldSize;
248+
249+
if (ptr == NULL)
250+
{
251+
retval = malloc(size);
252+
}
253+
else if (size == 0)
254+
{
255+
errno = EINVAL;
256+
retval = NULL;
257+
}
258+
else
259+
{
260+
packet = (Header *) ptr - 1;
261+
retval = malloc(size);
262+
if (retval != NULL)
263+
{
264+
oldSize = packet->header.size - sizeof(Header);
265+
(void) memcpy(retval, ptr, (size < oldSize) ? size : oldSize);
266+
free(ptr);
267+
}
268+
}
269+
270+
return (retval);
271+
#else
272+
/* Unsupported implementation */
273+
return (NULL);
274+
#endif
275+
}
276+
#endif
277+
237278
/*
238279
* ======== free ========
239280
*/

0 commit comments

Comments
 (0)