memory: use free() instead of realloc() for size 0
valgrind 3.21.0 reports realloc() of 0 bytes as an error due to having different behavior on different systems. The only place where this can happen in chrony is the array, which doesn't care what value realloc() returns. Modify the realloc wrapper to call free() in this case to make valgrind happy.
This commit is contained in:
parent
ca10b9e072
commit
109970f687
1 changed files with 6 additions and 1 deletions
7
memory.c
7
memory.c
|
@ -47,8 +47,13 @@ Realloc(void *ptr, size_t size)
|
|||
{
|
||||
void *r;
|
||||
|
||||
if (size == 0) {
|
||||
Free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r = realloc(ptr, size);
|
||||
if (!r && size)
|
||||
if (!r)
|
||||
LOG_FATAL("Could not allocate memory");
|
||||
|
||||
return r;
|
||||
|
|
Loading…
Reference in a new issue