Enforce strict include-what-you-use policy

The include-what-you-use (IWYU) policy is beneficial to faster
compilation and fewer recompilations. Many build tools, such as GNU make,
provide a mechanism for automatically figuring out what .h files a .cc
file depends on. These mechanisms typically look at #include lines. When
unnecessary #includes are listed, the build system is more likely to
recompile in cases where it is not necessary.

With the enforcement, header file <include/mimalloc.h> no longer
includes <stdlib.h>.

Reference:
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md
This commit is contained in:
Jim Huang 2019-07-21 23:21:14 +08:00 committed by daan
parent fe229f8fad
commit b5e26bedb1
8 changed files with 9 additions and 10 deletions

View file

@ -8,7 +8,8 @@ terms of the MIT license. A copy of the license can be found in the file
#include "mimalloc-internal.h"
#include "mimalloc-atomic.h"
#include <string.h> // memset
#include <string.h> // memset, memcpy, strlen
#include <stdlib.h> // malloc, exit
#define MI_IN_ALLOC_C
#include "alloc-override.c"
@ -465,7 +466,7 @@ char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name)
}
}
#else
#include <unistd.h>
#include <unistd.h> // pathconf
static size_t mi_path_max() {
static size_t path_max = 0;
if (path_max <= 0) {