From eee8a19447eaeb87fd38d11354a4adc29148963a Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 12 Nov 2018 15:04:02 +0200 Subject: some memory management hooks. fix motors homing --- .../Embedded_SW/Embedded/Common/Utilities/Utils.c | 38 ++++++++++++++-------- .../Embedded/Common/report/distributor.c | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common') diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index b1da049b2..d339ab66b 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -16,18 +16,23 @@ static const float speedCoef = 5.3051647697298445256294587790838f;//(200 micro s //***************************************************************************** -#define MAX_MEM_LOG 200 -int freeIndex=0,malloc_index=0; +#define MAX_MEM_LOG 300 +int free_index=0,malloc_index=0; +int zero_mallocs=0,null_free=0; uint32_t malloc_size[MAX_MEM_LOG]; uint32_t malloc_time[MAX_MEM_LOG]; void * malloc_addr[MAX_MEM_LOG]; -//void * free_addr[MAX_MEM_LOG]; +void * free_addr[MAX_MEM_LOG]; //uint32_t total_allocated = 0; void *my_malloc(size_t _size) { void * addr = malloc (_size); - if (_size == 0) return addr; - int i; + if (_size == 0) + { + zero_mallocs++; + return addr; + } + /*int i; for (i=0; i< MAX_MEM_LOG;i++) { if (malloc_time[i] == 0) @@ -42,12 +47,12 @@ void *my_malloc(size_t _size) malloc_addr[malloc_index] = addr; malloc_size[malloc_index] = _size; malloc_time[malloc_index] = msec_millisecondCounter; - } - //malloc_addr[malloc_index] = addr; - //malloc_size[malloc_index] = _size; - //malloc_time[malloc_index] = HibernateRTCSSGet(); - //if (malloc_index++>=MAX_MEM_LOG) - // malloc_index = 0; + }*/ + malloc_addr[malloc_index] = addr; + malloc_size[malloc_index] = _size; + malloc_time[malloc_index] = msec_millisecondCounter; + if (malloc_index++>=MAX_MEM_LOG) + malloc_index = 0; return addr; } int allocated_size = 0; @@ -57,7 +62,7 @@ void my_free(void *_ptr) free(_ptr); if (_ptr) { - for (i=0; i< MAX_MEM_LOG;i++) +/* for (i=0; i< MAX_MEM_LOG;i++) { if ( malloc_addr[i] == _ptr) { @@ -69,13 +74,20 @@ void my_free(void *_ptr) } if (i==MAX_MEM_LOG) { - LOG_ERROR(i,"free error"); + //LOG_ERROR(i,"free error"); return; } allocated_size = 0; // for (i=0; i< MAX_MEM_LOG;i++) // allocated_size+=malloc_size[i]; +*/ + free_addr[free_index] = _ptr; + if (free_index++>=MAX_MEM_LOG) + free_index = 0; + } + else + null_free++; } //***************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index 46a3affd6..cbc754a7e 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -240,7 +240,7 @@ Void reportService(UArg arg0, UArg arg1) int DistTableEntry;//,msgLen, errCode, par1, par2; ReportInitParams InitParams; - InitParams.DistributorQueueMaxMsgs = 20; + InitParams.DistributorQueueMaxMsgs = 15; InitParams.DistributorTaskPriority = 6; InitParams.MaxNumOfFilterNames = 1; InitParams.MaxNumberOfPrivateDistributors = 2; -- cgit v1.3.1