From 1e7f525e0e2ae361d7db9d71b267496de9adf09c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 11 Jan 2023 23:19:30 -0500 Subject: [PATCH] css: Avoid some allocations Avoid duplicating the function name just for an error message. --- gtk/css/gtkcssparser.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gtk/css/gtkcssparser.c b/gtk/css/gtkcssparser.c index 7668bfc70e..886e84f952 100644 --- a/gtk/css/gtkcssparser.c +++ b/gtk/css/gtkcssparser.c @@ -642,13 +642,13 @@ gtk_css_parser_consume_function (GtkCssParser *self, { const GtkCssToken *token; gboolean result = FALSE; - char *function_name; + char function_name[64]; guint arg; token = gtk_css_parser_get_token (self); g_return_val_if_fail (gtk_css_token_is (token, GTK_CSS_TOKEN_FUNCTION), FALSE); - function_name = g_strdup (token->string.string); + g_strlcpy (function_name, token->string.string, 64); gtk_css_parser_start_block (self); arg = 0; @@ -691,7 +691,6 @@ gtk_css_parser_consume_function (GtkCssParser *self, } gtk_css_parser_end_block (self); - g_free (function_name); return result; } @@ -756,7 +755,7 @@ gtk_css_parser_has_integer (GtkCssParser *self) * Checks if the next token is a function with the given @name. * * Returns: %TRUE if the next token is a function with the given @name - **/ + */ gboolean gtk_css_parser_has_function (GtkCssParser *self, const char *name) -- 2.30.2