From: Matthias Clasen Date: Thu, 12 Jan 2023 04:19:30 +0000 (-0500) Subject: css: Avoid some allocations X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~8^2~71^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1e7f525e0e2ae361d7db9d71b267496de9adf09c;p=gtk4.git css: Avoid some allocations Avoid duplicating the function name just for an error message. --- 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)