Does'n preinitialize memory when running for valgrind.

This commit is contained in:
Andrea Mazzoleni 2013-02-24 18:00:53 +01:00
parent f84ff1e74a
commit 027b6e3fcd
2 changed files with 10 additions and 0 deletions

2
util.c
View file

@ -722,6 +722,7 @@ void* malloc_nofail(size_t size)
exit(EXIT_FAILURE);
}
#ifndef CHECKER /* Don't preinitialize when running for valgrind */
/* Here we preinitialize the memory to ensure that the OS is really allocating it */
/* and not only reserving the addressable space. */
/* Otherwise we are risking that the OOM (Out Of Memory) killer in Linux will kill the process. */
@ -729,6 +730,7 @@ void* malloc_nofail(size_t size)
/* get a real error from malloc() instead than a process killed. */
/* Note that calloc() doesn't have the same effect. */
memset(ptr, 0xA5, size);
#endif
mcounter += size;