File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,16 +164,12 @@ void gtk_label_size_to_fit(GtkLabel * label, const gchar * str)
164164
165165 /* get a pointer to the current text */
166166 current_text = gtk_label_get_text (label );
167- /* how long is it */
168- text_len = strlen (current_text );
169- /* allocate memory to save it */
170- text_buf = malloc (text_len + 2 );
167+ /* make a temporary copy */
168+ text_buf = strdup (current_text );
171169 if (text_buf == NULL ) {
172- printf ("gtk_label_size_to_fit() - malloc failed\n" );
170+ printf ("gtk_label_size_to_fit() - strdup failed\n" );
173171 return ;
174172 }
175- /* save the text */
176- strncpy (text_buf , current_text , text_len + 1 );
177173 /* set the label to display the new text */
178174 gtk_label_set_text (label , str );
179175 /* how big is the label with the new text? */
You can’t perform that action at this time.
0 commit comments