]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:talloc: Don't optimize the speed test
authorAndreas Schneider <asn@samba.org>
Mon, 17 Apr 2023 07:25:48 +0000 (09:25 +0200)
committerMartin Schwenke <martins@samba.org>
Sat, 28 Sep 2024 00:11:34 +0000 (00:11 +0000)
If the speed test gets optimized, the malloc() and free() might be
replaced by stack allocations.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
lib/talloc/testsuite.c

index b67897efddf8e7d17d837165d492b80aeaeb4c6a..a4a3f4e89d101649d0e5a095b40e89f91d851426 100644 (file)
 
 #include "talloc_testsuite.h"
 
+#ifndef disable_optimization
+#if __has_attribute(optimize)
+#define disable_optimization __attribute__((optimize("O0")))
+#else /* disable_optimization */
+#define disable_optimization
+#endif
+#endif /* disable_optimization */
+
 static struct timeval private_timeval_current(void)
 {
        struct timeval tv;
@@ -854,6 +862,7 @@ static bool test_unref_reparent(void)
 /*
   measure the speed of talloc versus malloc
 */
+static bool test_speed(void) disable_optimization;
 static bool test_speed(void)
 {
        void *ctx = talloc_new(NULL);