Skip to content

Commit aa69b27

Browse files
authored
Merge pull request #2534 from niklas-arm/fix/calloc_wrapping
Fix missing wrapping of calloc_r with uVisor enabled
2 parents 22acfbf + 7c0cc50 commit aa69b27

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hal/common/retarget.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,11 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats)
500500
#include "uvisor-lib/uvisor-lib.h"
501501
#endif/* FEATURE_UVISOR */
502502

503-
#ifndef FEATURE_UVISOR
504503
extern "C" {
505504

505+
/* uVisor wraps malloc_r, realloc_r and free_r, but not calloc_r! */
506+
#ifndef FEATURE_UVISOR
507+
506508
extern "C" void __malloc_lock( struct _reent *_r );
507509
extern "C" void __malloc_unlock( struct _reent *_r );
508510

@@ -586,6 +588,9 @@ void __wrap__free_r(struct _reent * r, void * ptr) {
586588
malloc_stats_mutex->unlock();
587589
#endif
588590
}
591+
592+
#endif/* FEATURE_UVISOR */
593+
589594
void* __wrap__calloc_r(struct _reent * r, size_t num, size_t size) {
590595
#if !defined(MBED_HEAP_STATS_ENABLED ) || !MBED_HEAP_STATS_ENABLED
591596
extern void* __real__calloc_r(struct _reent * r, size_t num, size_t size);
@@ -603,7 +608,6 @@ void* __wrap__calloc_r(struct _reent * r, size_t num, size_t size) {
603608
#endif
604609
}
605610
}
606-
#endif/* FEATURE_UVISOR */
607611

608612
extern "C" WEAK void software_init_hook_rtos(void)
609613
{

0 commit comments

Comments
 (0)