Just use a volatile static in Malloc.h
[folly.git] / folly / memory / Malloc.h
index 2726c9d8f12575637966d1abb4b88c997a1c2257..5bad7484a9a5dc2a524bb3d38e94a513061a45e7 100644 (file)
@@ -183,15 +183,12 @@ FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept {
 
     uint64_t origAllocated = *counter;
 
-    const void* ptr = malloc(1);
+    static const void* volatile ptr = malloc(1);
     if (!ptr) {
       // wtf, failing to allocate 1 byte
       return false;
     }
 
-    /* Avoid optimizing away the malloc.  */
-    asm volatile("" ::"m"(ptr) : "memory");
-
     return (origAllocated != *counter);
   }();