From: Alan T. DeKok Date: Thu, 12 Dec 2019 15:49:25 +0000 (-0500) Subject: don't call snprintf() in the hot path. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c429c3e4264359f0e98715975a47bc720b542e7;p=thirdparty%2Ffreeradius-server.git don't call snprintf() in the hot path. 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. --- diff --git a/src/lib/tls/base.c b/src/lib/tls/base.c index cca4b36f1ee..99bec4b56c6 100644 --- a/src/lib/tls/base.c +++ b/src/lib/tls/base.c @@ -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) {