diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-01-11 23:19:30 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2023-01-12 00:12:09 -0500 |
commit | 1e7f525e0e2ae361d7db9d71b267496de9adf09c (patch) | |
tree | f216e54c1192b1113b41eac3042e89fae41acb98 | |
parent | d43e0fb9a72b411550cc4b937f63b89dc0cb74f3 (diff) | |
download | gtk+-1e7f525e0e2ae361d7db9d71b267496de9adf09c.tar.gz |
css: Avoid some allocations
Avoid duplicating the function name just
for an error message.
-rw-r--r-- | gtk/css/gtkcssparser.c | 7 |
1 files 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) |