Skip to content
Snippets Groups Projects
Commit 1cf32fa4 authored by Suvendhu Hansa's avatar Suvendhu Hansa :speech_balloon: Committed by Vivek Dutta
Browse files

Fix compilation error

parent 6df13f66
Branches devel
No related tags found
1 merge request!12Fix compile error
Pipeline #144781 passed
......@@ -270,9 +270,6 @@ void USP_MEM_Free(const char *func, int line, void *ptr)
{
minfo_t *mi;
// Free the memory
free(ptr);
#ifndef __clang_analyzer__
// Clang static analyser goes wrong here because the ptr in meminfo is just an address used as a key; ptr is not owned by meminfo
......@@ -293,6 +290,9 @@ void USP_MEM_Free(const char *func, int line, void *ptr)
OS_UTILS_UnlockMutex(&mem_access_mutex);
}
#endif
// Free the memory
free(ptr);
}
/*********************************************************************//**
......@@ -311,16 +311,9 @@ void USP_MEM_Free(const char *func, int line, void *ptr)
**************************************************************************/
void *USP_MEM_Realloc(const char *func, int line, void *ptr, int size)
{
minfo_t *mi;
minfo_t *mi = NULL;
void *new_ptr;
// Terminate if out of memory
new_ptr = realloc(ptr, size);
if (new_ptr == NULL)
{
USP_ERR_Terminate("%s (%d): realloc(%d bytes) failed", func, line, size);
}
#ifndef __clang_analyzer__
// Clang static analyser goes wrong here because the ptr in meminfo is just an address used as a key; ptr is not owned by meminfo
......@@ -330,19 +323,29 @@ void *USP_MEM_Realloc(const char *func, int line, void *ptr, int size)
OS_UTILS_LockMutex(&mem_access_mutex);
tr_mem("%s(%d): realloc(%p, %d) = %p", func, line, ptr, size, new_ptr);
mi = FindMemInfoByPtr(ptr);
if (mi != NULL)
{
mi->ptr = new_ptr;
mi->func = func;
mi->line = line;
mi->size = size;
mi->flags |= MI_MODIFIED;
GetCallers(mi->callers, NUM_ELEM(mi->callers));
}
else
if (mi == NULL)
{
USP_ERR_Terminate("Trying to reallocate memory that was not allocated");
}
}
#endif
// Terminate if out of memory
new_ptr = realloc(ptr, size);
if (new_ptr == NULL)
{
USP_ERR_Terminate("%s (%d): realloc(%d bytes) failed", func, line, size);
}
#ifndef __clang_analyzer__
if ((collect_memory_info) && (mi != NULL))
{
mi->ptr = new_ptr;
mi->func = func;
mi->line = line;
mi->size = size;
mi->flags |= MI_MODIFIED;
GetCallers(mi->callers, NUM_ELEM(mi->callers));
OS_UTILS_UnlockMutex(&mem_access_mutex);
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment