]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't call snprintf() in the hot path.
authorAlan T. DeKok <aland@freeradius.org>
Thu, 12 Dec 2019 15:49:25 +0000 (10:49 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 12 Dec 2019 15:53:14 +0000 (10:53 -0500)
If we don't have debugging symbols enabled, then performance
is likely more important than debugging.  If debugging symbols
are enabled, then small performance hits aren't much of an issue.

src/lib/tls/base.c

index cca4b36f1ee1b24069a45330b4aa1d9c40f38761..99bec4b56c64d21883044b2f5a3eced892f47692 100644 (file)
@@ -424,14 +424,26 @@ static void *openssl_realloc(void *old, size_t len)
  * @param to_free memory to free.
  */
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef NDEBUG
+/*
+ *     If we're not debugging, use only the filename.  Otherwise the
+ *     cost of snprintf() is too large.
+ */
+static void openssl_free(void *to_free, char const *file, UNUSED int line)
+{
+       (void)_talloc_free(to_free, file);
+}
+#else
 static void openssl_free(void *to_free, char const *file, int line)
 {
+       (void)_talloc_free(to_free, file);
+
        char buffer[256];
 
        snprintf(buffer, sizeof(buffer), "%s:%i", file, line);
-
        (void)_talloc_free(to_free, buffer);
 }
+#endif
 #else
 static void openssl_free(void *to_free)
 {