GIO MSVC Project: Link to iphlpapi.lib
[platform/upstream/glib.git] / glib / gslice.c
index a1a7e9a..e380b9f 100644 (file)
@@ -53,6 +53,8 @@
 #include "gthread.h"
 #include "glib_trace.h"
 
+#include "valgrind.h"
+
 /**
  * SECTION:memory_slices
  * @title: Memory Slices
@@ -382,6 +384,17 @@ slice_config_init (SliceConfig *config)
       if (flags & (1 << 1))
         config->debug_blocks = TRUE;
     }
+  else
+    {
+      /* G_SLICE was not specified, so check if valgrind is running and
+       * disable ourselves if it is.
+       *
+       * This way it's possible to force gslice to be enabled under
+       * valgrind just by setting G_SLICE to the empty string.
+       */
+      if (RUNNING_ON_VALGRIND)
+        config->always_malloc = TRUE;
+    }
 }
 
 static void
@@ -410,7 +423,7 @@ g_slice_init_nomessage (void)
    * fit less than 8 times (see [4]) into 4KB pages.
    * we allow very small page sizes here, to reduce wastage in
    * threads if only small allocations are required (this does
-   * bear the risk of incresing allocation times and fragmentation
+   * bear the risk of increasing allocation times and fragmentation
    * though).
    */
   allocator->min_page_size = MAX (allocator->min_page_size, 4096);
@@ -1509,7 +1522,7 @@ smc_notify_free (void   *pointer,
 /* --- g-slice memory checker tree implementation --- */
 #define SMC_TRUNK_COUNT     (4093 /* 16381 */)          /* prime, to distribute trunk collisions (big, allocated just once) */
 #define SMC_BRANCH_COUNT    (511)                       /* prime, to distribute branch collisions */
-#define SMC_TRUNK_EXTENT    (SMC_BRANCH_COUNT * 2039)   /* key adress space per trunk, should distribute uniformly across BRANCH_COUNT */
+#define SMC_TRUNK_EXTENT    (SMC_BRANCH_COUNT * 2039)   /* key address space per trunk, should distribute uniformly across BRANCH_COUNT */
 #define SMC_TRUNK_HASH(k)   ((k / SMC_TRUNK_EXTENT) % SMC_TRUNK_COUNT)  /* generate new trunk hash per megabyte (roughly) */
 #define SMC_BRANCH_HASH(k)  (k % SMC_BRANCH_COUNT)