gdb/tui: Remove casts of NULL during assignment.
[external/binutils.git] / gdb / tui / tui-data.c
1 /* TUI data manipulation routines.
2
3    Copyright (C) 1998-2015 Free Software Foundation, Inc.
4
5    Contributed by Hewlett-Packard Company.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
22 #include "defs.h"
23 #include "symtab.h"
24 #include "tui/tui.h"
25 #include "tui/tui-data.h"
26 #include "tui/tui-wingeneral.h"
27 #include "gdb_curses.h"
28
29 /****************************
30 ** GLOBAL DECLARATIONS
31 ****************************/
32 struct tui_win_info *(tui_win_list[MAX_MAJOR_WINDOWS]);
33
34 /***************************
35 ** Private data
36 ****************************/
37 static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
38 static int term_height, term_width;
39 static struct tui_gen_win_info _locator;
40 static struct tui_gen_win_info exec_info[2];
41 static struct tui_win_info *src_win_list[2];
42 static struct tui_list source_windows = {src_win_list, 0};
43 static int default_tab_len = DEFAULT_TAB_LEN;
44 static struct tui_win_info *win_with_focus = NULL;
45 static struct tui_layout_def layout_def = {
46   SRC_WIN,                      /* DISPLAY_MODE */
47   FALSE};                       /* SPLIT */
48
49 static int win_resized = FALSE;
50
51
52 /*********************************
53 ** Static function forward decls
54 **********************************/
55 static void free_content (tui_win_content, 
56                           int, 
57                           enum tui_win_type);
58 static void free_content_elements (tui_win_content, 
59                                    int, 
60                                    enum tui_win_type);
61
62
63
64 /*********************************
65 ** PUBLIC FUNCTIONS
66 **********************************/
67
68 int
69 tui_win_is_source_type (enum tui_win_type win_type)
70 {
71   return (win_type == SRC_WIN || win_type == DISASSEM_WIN);
72 }
73
74 int
75 tui_win_is_auxillary (enum tui_win_type win_type)
76 {
77   return (win_type > MAX_MAJOR_WINDOWS);
78 }
79
80 int
81 tui_win_has_locator (struct tui_win_info *win_info)
82 {
83   return (win_info != NULL 
84           && win_info->detail.source_info.has_locator);
85 }
86
87 void
88 tui_set_win_highlight (struct tui_win_info *win_info, 
89                        int highlight)
90 {
91   if (win_info != NULL)
92     win_info->is_highlighted = highlight;
93 }
94
95 /******************************************
96 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
97 ******************************************/
98
99 /* Answer a whether the terminal window has been resized or not.  */
100 int
101 tui_win_resized (void)
102 {
103   return win_resized;
104 }
105
106
107 /* Set a whether the terminal window has been resized or not.  */
108 void
109 tui_set_win_resized_to (int resized)
110 {
111   win_resized = resized;
112 }
113
114
115 /* Answer a pointer to the current layout definition.  */
116 struct tui_layout_def *
117 tui_layout_def (void)
118 {
119   return &layout_def;
120 }
121
122
123 /* Answer the window with the logical focus.  */
124 struct tui_win_info *
125 tui_win_with_focus (void)
126 {
127   return win_with_focus;
128 }
129
130
131 /* Set the window that has the logical focus.  */
132 void
133 tui_set_win_with_focus (struct tui_win_info *win_info)
134 {
135   win_with_focus = win_info;
136 }
137
138
139 /* Answer the length in chars, of tabs.  */
140 int
141 tui_default_tab_len (void)
142 {
143   return default_tab_len;
144 }
145
146
147 /* Set the length in chars, of tabs.  */
148 void
149 tui_set_default_tab_len (int len)
150 {
151   default_tab_len = len;
152 }
153
154
155 /* Accessor for the current source window.  Usually there is only one
156    source window (either source or disassembly), but both can be
157    displayed at the same time.  */
158 struct tui_list *
159 tui_source_windows (void)
160 {
161   return &source_windows;
162 }
163
164
165 /* Clear the list of source windows.  Usually there is only one source
166    window (either source or disassembly), but both can be displayed at
167    the same time.  */
168 void
169 tui_clear_source_windows (void)
170 {
171   source_windows.list[0] = NULL;
172   source_windows.list[1] = NULL;
173   source_windows.count = 0;
174 }
175
176
177 /* Clear the pertinant detail in the source windows.  */
178 void
179 tui_clear_source_windows_detail (void)
180 {
181   int i;
182
183   for (i = 0; i < (tui_source_windows ())->count; i++)
184     tui_clear_win_detail ((tui_source_windows ())->list[i]);
185 }
186
187
188 /* Add a window to the list of source windows.  Usually there is only
189    one source window (either source or disassembly), but both can be
190    displayed at the same time.  */
191 void
192 tui_add_to_source_windows (struct tui_win_info *win_info)
193 {
194   if (source_windows.count < 2)
195     source_windows.list[source_windows.count++] = (void *) win_info;
196 }
197
198
199 /* Clear the pertinant detail in the windows.  */
200 void
201 tui_clear_win_detail (struct tui_win_info *win_info)
202 {
203   if (win_info != NULL)
204     {
205       switch (win_info->generic.type)
206         {
207         case SRC_WIN:
208         case DISASSEM_WIN:
209           win_info->detail.source_info.gdbarch = NULL;
210           win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
211           win_info->detail.source_info.start_line_or_addr.u.addr = 0;
212           win_info->detail.source_info.horizontal_offset = 0;
213           break;
214         case CMD_WIN:
215           wmove (win_info->generic.handle, 0, 0);
216           break;
217         case DATA_WIN:
218           win_info->detail.data_display_info.data_content =
219             (tui_win_content) NULL;
220           win_info->detail.data_display_info.data_content_count = 0;
221           win_info->detail.data_display_info.regs_content =
222             (tui_win_content) NULL;
223           win_info->detail.data_display_info.regs_content_count = 0;
224           win_info->detail.data_display_info.regs_column_count = 1;
225           win_info->detail.data_display_info.display_regs = FALSE;
226           break;
227         default:
228           break;
229         }
230     }
231 }
232
233
234 /* Accessor for the source execution info ptr.  */
235 struct tui_gen_win_info *
236 tui_source_exec_info_win_ptr (void)
237 {
238   return &exec_info[0];
239 }
240
241
242 /* Accessor for the disassem execution info ptr.  */
243 struct tui_gen_win_info *
244 tui_disassem_exec_info_win_ptr (void)
245 {
246   return &exec_info[1];
247 }
248
249
250 /* Accessor for the locator win info.  Answers a pointer to the static
251    locator win info struct.  */
252 struct tui_gen_win_info *
253 tui_locator_win_info_ptr (void)
254 {
255   return &_locator;
256 }
257
258
259 /* Accessor for the term_height.  */
260 int
261 tui_term_height (void)
262 {
263   return term_height;
264 }
265
266
267 /* Mutator for the term height.  */
268 void
269 tui_set_term_height_to (int h)
270 {
271   term_height = h;
272 }
273
274
275 /* Accessor for the term_width.  */
276 int
277 tui_term_width (void)
278 {
279   return term_width;
280 }
281
282
283 /* Mutator for the term_width.  */
284 void
285 tui_set_term_width_to (int w)
286 {
287   term_width = w;
288 }
289
290
291 /* Accessor for the current layout.  */
292 enum tui_layout_type
293 tui_current_layout (void)
294 {
295   return current_layout;
296 }
297
298
299 /* Mutator for the current layout.  */
300 void
301 tui_set_current_layout_to (enum tui_layout_type new_layout)
302 {
303   current_layout = new_layout;
304 }
305
306
307 /*****************************
308 ** OTHER PUBLIC FUNCTIONS
309 *****************************/
310
311
312 /* Answer the next window in the list, cycling back to the top if
313    necessary.  */
314 struct tui_win_info *
315 tui_next_win (struct tui_win_info *cur_win)
316 {
317   int type = cur_win->generic.type;
318   struct tui_win_info *next_win = NULL;
319
320   if (cur_win->generic.type == CMD_WIN)
321     type = SRC_WIN;
322   else
323     type = cur_win->generic.type + 1;
324   while (type != cur_win->generic.type && (next_win == NULL))
325     {
326       if (tui_win_list[type]
327           && tui_win_list[type]->generic.is_visible)
328         next_win = tui_win_list[type];
329       else
330         {
331           if (type == CMD_WIN)
332             type = SRC_WIN;
333           else
334             type++;
335         }
336     }
337
338   return next_win;
339 }
340
341
342 /* Answer the prev window in the list, cycling back to the bottom if
343    necessary.  */
344 struct tui_win_info *
345 tui_prev_win (struct tui_win_info *cur_win)
346 {
347   int type = cur_win->generic.type;
348   struct tui_win_info *prev = NULL;
349
350   if (cur_win->generic.type == SRC_WIN)
351     type = CMD_WIN;
352   else
353     type = cur_win->generic.type - 1;
354   while (type != cur_win->generic.type && (prev == NULL))
355     {
356       if (tui_win_list[type]
357           && tui_win_list[type]->generic.is_visible)
358         prev = tui_win_list[type];
359       else
360         {
361           if (type == SRC_WIN)
362             type = CMD_WIN;
363           else
364             type--;
365         }
366     }
367
368   return prev;
369 }
370
371
372 /* Answer the window represented by name.  */
373 struct tui_win_info *
374 tui_partial_win_by_name (char *name)
375 {
376   struct tui_win_info *win_info = NULL;
377
378   if (name != (char *) NULL)
379     {
380       int i = 0;
381
382       while (i < MAX_MAJOR_WINDOWS && win_info == NULL)
383         {
384           if (tui_win_list[i] != 0)
385             {
386               const char *cur_name =
387                 tui_win_name (&tui_win_list[i]->generic);
388
389               if (strlen (name) <= strlen (cur_name)
390                   && startswith (cur_name, name))
391                 win_info = tui_win_list[i];
392             }
393           i++;
394         }
395     }
396
397   return win_info;
398 }
399
400
401 /* Answer the name of the window.  */
402 const char *
403 tui_win_name (const struct tui_gen_win_info *win_info)
404 {
405   const char *name = NULL;
406
407   switch (win_info->type)
408     {
409     case SRC_WIN:
410       name = SRC_NAME;
411       break;
412     case CMD_WIN:
413       name = CMD_NAME;
414       break;
415     case DISASSEM_WIN:
416       name = DISASSEM_NAME;
417       break;
418     case DATA_WIN:
419       name = DATA_NAME;
420       break;
421     default:
422       name = "";
423       break;
424     }
425
426   return name;
427 }
428
429
430 void
431 tui_initialize_static_data (void)
432 {
433   tui_init_generic_part (tui_source_exec_info_win_ptr ());
434   tui_init_generic_part (tui_disassem_exec_info_win_ptr ());
435   tui_init_generic_part (tui_locator_win_info_ptr ());
436 }
437
438
439 struct tui_gen_win_info *
440 tui_alloc_generic_win_info (void)
441 {
442   struct tui_gen_win_info *win = XNEW (struct tui_gen_win_info);
443
444   if (win != NULL)
445     tui_init_generic_part (win);
446
447   return win;
448 }
449
450
451 void
452 tui_init_generic_part (struct tui_gen_win_info *win)
453 {
454   win->width =
455     win->height =
456     win->origin.x =
457     win->origin.y =
458     win->viewport_height =
459     win->content_size =
460     win->last_visible_line = 0;
461   win->handle = NULL;
462   win->content = NULL;
463   win->content_in_use =
464     win->is_visible = FALSE;
465   win->title = 0;
466 }
467
468
469 /* init_content_element().
470  */
471 static void
472 init_content_element (struct tui_win_element *element, 
473                       enum tui_win_type type)
474 {
475   element->highlight = FALSE;
476   switch (type)
477     {
478     case SRC_WIN:
479     case DISASSEM_WIN:
480       element->which_element.source.line = NULL;
481       element->which_element.source.line_or_addr.loa = LOA_LINE;
482       element->which_element.source.line_or_addr.u.line_no = 0;
483       element->which_element.source.is_exec_point = FALSE;
484       element->which_element.source.has_break = FALSE;
485       break;
486     case DATA_WIN:
487       tui_init_generic_part (&element->which_element.data_window);
488       element->which_element.data_window.type = DATA_ITEM_WIN;
489       element->which_element.data_window.content =
490         tui_alloc_content (1, DATA_ITEM_WIN);
491       element->which_element.data_window.content_size = 1;
492       break;
493     case CMD_WIN:
494       element->which_element.command.line = NULL;
495       break;
496     case DATA_ITEM_WIN:
497       element->which_element.data.name = NULL;
498       element->which_element.data.type = TUI_REGISTER;
499       element->which_element.data.item_no = UNDEFINED_ITEM;
500       element->which_element.data.value = NULL;
501       element->which_element.data.highlight = FALSE;
502       element->which_element.data.content = NULL;
503       break;
504     case LOCATOR_WIN:
505       element->which_element.locator.full_name[0] =
506         element->which_element.locator.proc_name[0] = (char) 0;
507       element->which_element.locator.line_no = 0;
508       element->which_element.locator.addr = 0;
509       break;
510     case EXEC_INFO_WIN:
511       memset(element->which_element.simple_string, ' ',
512              sizeof(element->which_element.simple_string));
513       break;
514     default:
515       break;
516     }
517 }
518
519 static void
520 init_win_info (struct tui_win_info *win_info)
521 {
522   tui_init_generic_part (&win_info->generic);
523   win_info->can_highlight =
524     win_info->is_highlighted = FALSE;
525   switch (win_info->generic.type)
526     {
527     case SRC_WIN:
528     case DISASSEM_WIN:
529       win_info->detail.source_info.execution_info
530         = (struct tui_gen_win_info *) NULL;
531       win_info->detail.source_info.has_locator = FALSE;
532       win_info->detail.source_info.horizontal_offset = 0;
533       win_info->detail.source_info.gdbarch = NULL;
534       win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
535       win_info->detail.source_info.start_line_or_addr.u.addr = 0;
536       win_info->detail.source_info.fullname = NULL;
537       break;
538     case DATA_WIN:
539       win_info->detail.data_display_info.data_content = (tui_win_content) NULL;
540       win_info->detail.data_display_info.data_content_count = 0;
541       win_info->detail.data_display_info.regs_content = (tui_win_content) NULL;
542       win_info->detail.data_display_info.regs_content_count = 0;
543       win_info->detail.data_display_info.regs_column_count = 1;
544       win_info->detail.data_display_info.display_regs = FALSE;
545       win_info->detail.data_display_info.current_group = 0;
546       break;
547     case CMD_WIN:
548       break;
549     default:
550       win_info->detail.opaque = NULL;
551       break;
552     }
553 }
554
555
556 struct tui_win_info *
557 tui_alloc_win_info (enum tui_win_type type)
558 {
559   struct tui_win_info *win_info = XNEW (struct tui_win_info);
560
561   if (win_info != NULL)
562     {
563       win_info->generic.type = type;
564       init_win_info (win_info);
565     }
566
567   return win_info;
568 }
569
570
571 /* Allocates the content and elements in a block.  */
572 tui_win_content
573 tui_alloc_content (int num_elements, enum tui_win_type type)
574 {
575   tui_win_content content;
576   char *element_block_ptr;
577   int i;
578
579   content = XNEWVEC (struct tui_win_element *, num_elements);
580   if (content != NULL)
581     {
582       /*
583        * All windows, except the data window, can allocate the
584        * elements in a chunk.  The data window cannot because items
585        * can be added/removed from the data display by the user at any
586        * time.
587        */
588       if (type != DATA_WIN)
589         {
590           element_block_ptr =
591             xmalloc (sizeof (struct tui_win_element) * num_elements);
592           if (element_block_ptr != NULL)
593             {
594               for (i = 0; i < num_elements; i++)
595                 {
596                   content[i] = (struct tui_win_element *) element_block_ptr;
597                   init_content_element (content[i], type);
598                   element_block_ptr += sizeof (struct tui_win_element);
599                 }
600             }
601           else
602             {
603               xfree (content);
604               content = (tui_win_content) NULL;
605             }
606         }
607     }
608
609   return content;
610 }
611
612
613 /* Adds the input number of elements to the windows's content.  If no
614    content has been allocated yet, alloc_content() is called to do
615    this.  The index of the first element added is returned, unless
616    there is a memory allocation error, in which case, (-1) is
617    returned.  */
618 int
619 tui_add_content_elements (struct tui_gen_win_info *win_info, 
620                           int num_elements)
621 {
622   struct tui_win_element *element_ptr;
623   int i, index_start;
624
625   if (win_info->content == NULL)
626     {
627       win_info->content = tui_alloc_content (num_elements, win_info->type);
628       index_start = 0;
629     }
630   else
631     index_start = win_info->content_size;
632   if (win_info->content != NULL)
633     {
634       for (i = index_start; (i < num_elements + index_start); i++)
635         {
636           element_ptr = XNEW (struct tui_win_element);
637           if (element_ptr != NULL)
638             {
639               win_info->content[i] = (void *) element_ptr;
640               init_content_element (element_ptr, win_info->type);
641               win_info->content_size++;
642             }
643           else  /* Things must be really hosed now!  We ran out of
644                    memory!?  */
645             return (-1);
646         }
647     }
648
649   return index_start;
650 }
651
652
653 /* Delete all curses windows associated with win_info, leaving
654    everything else intact.  */
655 void
656 tui_del_window (struct tui_win_info *win_info)
657 {
658   struct tui_gen_win_info *generic_win;
659
660   switch (win_info->generic.type)
661     {
662     case SRC_WIN:
663     case DISASSEM_WIN:
664       generic_win = tui_locator_win_info_ptr ();
665       if (generic_win != (struct tui_gen_win_info *) NULL)
666         {
667           tui_delete_win (generic_win->handle);
668           generic_win->handle = NULL;
669           generic_win->is_visible = FALSE;
670         }
671       if (win_info->detail.source_info.fullname)
672         {
673           xfree (win_info->detail.source_info.fullname);
674           win_info->detail.source_info.fullname = NULL;
675         }
676       generic_win = win_info->detail.source_info.execution_info;
677       if (generic_win != (struct tui_gen_win_info *) NULL)
678         {
679           tui_delete_win (generic_win->handle);
680           generic_win->handle = NULL;
681           generic_win->is_visible = FALSE;
682         }
683       break;
684     case DATA_WIN:
685       if (win_info->generic.content != NULL)
686         {
687           tui_del_data_windows (win_info->detail.data_display_info.regs_content,
688                                 win_info->detail.data_display_info.regs_content_count);
689           tui_del_data_windows (win_info->detail.data_display_info.data_content,
690                                 win_info->detail.data_display_info.data_content_count);
691         }
692       break;
693     default:
694       break;
695     }
696   if (win_info->generic.handle != (WINDOW *) NULL)
697     {
698       tui_delete_win (win_info->generic.handle);
699       win_info->generic.handle = NULL;
700       win_info->generic.is_visible = FALSE;
701     }
702 }
703
704
705 void
706 tui_free_window (struct tui_win_info *win_info)
707 {
708   struct tui_gen_win_info *generic_win;
709
710   switch (win_info->generic.type)
711     {
712     case SRC_WIN:
713     case DISASSEM_WIN:
714       if (win_info->detail.source_info.fullname)
715         {
716           xfree (win_info->detail.source_info.fullname);
717           win_info->detail.source_info.fullname = NULL;
718         }
719       generic_win = win_info->detail.source_info.execution_info;
720       if (generic_win != (struct tui_gen_win_info *) NULL)
721         {
722           tui_delete_win (generic_win->handle);
723           generic_win->handle = NULL;
724           tui_free_win_content (generic_win);
725         }
726       break;
727     case DATA_WIN:
728       if (win_info->generic.content != NULL)
729         {
730           tui_free_data_content (win_info->detail.data_display_info.regs_content,
731                                  win_info->detail.data_display_info.regs_content_count);
732           win_info->detail.data_display_info.regs_content =
733             (tui_win_content) NULL;
734           win_info->detail.data_display_info.regs_content_count = 0;
735           tui_free_data_content (win_info->detail.data_display_info.data_content,
736                                  win_info->detail.data_display_info.data_content_count);
737           win_info->detail.data_display_info.data_content =
738             (tui_win_content) NULL;
739           win_info->detail.data_display_info.data_content_count = 0;
740           win_info->detail.data_display_info.regs_column_count = 1;
741           win_info->detail.data_display_info.display_regs = FALSE;
742           win_info->generic.content = NULL;
743           win_info->generic.content_size = 0;
744         }
745       break;
746     default:
747       break;
748     }
749   if (win_info->generic.handle != (WINDOW *) NULL)
750     {
751       tui_delete_win (win_info->generic.handle);
752       win_info->generic.handle = NULL;
753       tui_free_win_content (&win_info->generic);
754     }
755   if (win_info->generic.title)
756     xfree (win_info->generic.title);
757   xfree (win_info);
758 }
759
760
761 void
762 tui_free_all_source_wins_content (void)
763 {
764   int i;
765
766   for (i = 0; i < (tui_source_windows ())->count; i++)
767     {
768       struct tui_win_info *win_info = (tui_source_windows ())->list[i];
769
770       if (win_info != NULL)
771         {
772           tui_free_win_content (&(win_info->generic));
773           tui_free_win_content (win_info->detail.source_info.execution_info);
774         }
775     }
776 }
777
778
779 void
780 tui_free_win_content (struct tui_gen_win_info *win_info)
781 {
782   if (win_info->content != NULL)
783     {
784       free_content ((tui_win_content) win_info->content,
785                    win_info->content_size,
786                    win_info->type);
787       win_info->content = NULL;
788     }
789   win_info->content_size = 0;
790 }
791
792
793 void
794 tui_del_data_windows (tui_win_content content, 
795                       int content_size)
796 {
797   int i;
798
799   /* Remember that data window content elements are of type struct
800      tui_gen_win_info *, each of which whose single element is a data
801      element.  */
802   for (i = 0; i < content_size; i++)
803     {
804       struct tui_gen_win_info *generic_win
805         = &content[i]->which_element.data_window;
806
807       if (generic_win != (struct tui_gen_win_info *) NULL)
808         {
809           tui_delete_win (generic_win->handle);
810           generic_win->handle = NULL;
811           generic_win->is_visible = FALSE;
812         }
813     }
814 }
815
816
817 void
818 tui_free_data_content (tui_win_content content, 
819                        int content_size)
820 {
821   int i;
822
823   /* Remember that data window content elements are of type struct
824      tui_gen_win_info *, each of which whose single element is a data
825      element.  */
826   for (i = 0; i < content_size; i++)
827     {
828       struct tui_gen_win_info *generic_win
829         = &content[i]->which_element.data_window;
830
831       if (generic_win != (struct tui_gen_win_info *) NULL)
832         {
833           tui_delete_win (generic_win->handle);
834           generic_win->handle = NULL;
835           tui_free_win_content (generic_win);
836         }
837     }
838   free_content (content,
839                 content_size,
840                 DATA_WIN);
841 }
842
843
844 /**********************************
845 ** LOCAL STATIC FUNCTIONS        **
846 **********************************/
847
848
849 static void
850 free_content (tui_win_content content, 
851               int content_size, 
852               enum tui_win_type win_type)
853 {
854   if (content != (tui_win_content) NULL)
855     {
856       free_content_elements (content, content_size, win_type);
857       xfree (content);
858     }
859 }
860
861
862 /* free_content_elements().
863  */
864 static void
865 free_content_elements (tui_win_content content, 
866                        int content_size, 
867                        enum tui_win_type type)
868 {
869   if (content != (tui_win_content) NULL)
870     {
871       int i;
872
873       if (type == SRC_WIN || type == DISASSEM_WIN)
874         {
875           /* Free whole source block.  */
876           xfree (content[0]->which_element.source.line);
877         }
878       else
879         {
880           for (i = 0; i < content_size; i++)
881             {
882               struct tui_win_element *element;
883
884               element = content[i];
885               if (element != (struct tui_win_element *) NULL)
886                 {
887                   switch (type)
888                     {
889                     case DATA_WIN:
890                       xfree (element);
891                       break;
892                     case DATA_ITEM_WIN:
893                       /* Note that data elements are not allocated in
894                          a single block, but individually, as
895                          needed.  */
896                       if (element->which_element.data.type != TUI_REGISTER)
897                         xfree ((void *)element->which_element.data.name);
898                       xfree (element->which_element.data.value);
899                       xfree (element->which_element.data.content);
900                       xfree (element);
901                       break;
902                     case CMD_WIN:
903                       xfree (element->which_element.command.line);
904                       break;
905                     default:
906                       break;
907                     }
908                 }
909             }
910         }
911       if (type != DATA_WIN && type != DATA_ITEM_WIN)
912         xfree (content[0]);     /* Free the element block.  */
913     }
914 }