gdb: tui_win_name: Make parameter and result const.
[deliverable/binutils-gdb.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 = (struct tui_win_info *) 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 win_info->detail.command_info.cur_line =
216 win_info->detail.command_info.curch = 0;
217 break;
218 case DATA_WIN:
219 win_info->detail.data_display_info.data_content =
220 (tui_win_content) NULL;
221 win_info->detail.data_display_info.data_content_count = 0;
222 win_info->detail.data_display_info.regs_content =
223 (tui_win_content) NULL;
224 win_info->detail.data_display_info.regs_content_count = 0;
225 win_info->detail.data_display_info.regs_column_count = 1;
226 win_info->detail.data_display_info.display_regs = FALSE;
227 break;
228 default:
229 break;
230 }
231 }
232 }
233
234
235 /* Accessor for the source execution info ptr. */
236 struct tui_gen_win_info *
237 tui_source_exec_info_win_ptr (void)
238 {
239 return &exec_info[0];
240 }
241
242
243 /* Accessor for the disassem execution info ptr. */
244 struct tui_gen_win_info *
245 tui_disassem_exec_info_win_ptr (void)
246 {
247 return &exec_info[1];
248 }
249
250
251 /* Accessor for the locator win info. Answers a pointer to the static
252 locator win info struct. */
253 struct tui_gen_win_info *
254 tui_locator_win_info_ptr (void)
255 {
256 return &_locator;
257 }
258
259
260 /* Accessor for the term_height. */
261 int
262 tui_term_height (void)
263 {
264 return term_height;
265 }
266
267
268 /* Mutator for the term height. */
269 void
270 tui_set_term_height_to (int h)
271 {
272 term_height = h;
273 }
274
275
276 /* Accessor for the term_width. */
277 int
278 tui_term_width (void)
279 {
280 return term_width;
281 }
282
283
284 /* Mutator for the term_width. */
285 void
286 tui_set_term_width_to (int w)
287 {
288 term_width = w;
289 }
290
291
292 /* Accessor for the current layout. */
293 enum tui_layout_type
294 tui_current_layout (void)
295 {
296 return current_layout;
297 }
298
299
300 /* Mutator for the current layout. */
301 void
302 tui_set_current_layout_to (enum tui_layout_type new_layout)
303 {
304 current_layout = new_layout;
305 }
306
307
308 /*****************************
309 ** OTHER PUBLIC FUNCTIONS
310 *****************************/
311
312
313 /* Answer the next window in the list, cycling back to the top if
314 necessary. */
315 struct tui_win_info *
316 tui_next_win (struct tui_win_info *cur_win)
317 {
318 int type = cur_win->generic.type;
319 struct tui_win_info *next_win = (struct tui_win_info *) NULL;
320
321 if (cur_win->generic.type == CMD_WIN)
322 type = SRC_WIN;
323 else
324 type = cur_win->generic.type + 1;
325 while (type != cur_win->generic.type && (next_win == NULL))
326 {
327 if (tui_win_list[type]
328 && tui_win_list[type]->generic.is_visible)
329 next_win = tui_win_list[type];
330 else
331 {
332 if (type == CMD_WIN)
333 type = SRC_WIN;
334 else
335 type++;
336 }
337 }
338
339 return next_win;
340 }
341
342
343 /* Answer the prev window in the list, cycling back to the bottom if
344 necessary. */
345 struct tui_win_info *
346 tui_prev_win (struct tui_win_info *cur_win)
347 {
348 int type = cur_win->generic.type;
349 struct tui_win_info *prev = (struct tui_win_info *) NULL;
350
351 if (cur_win->generic.type == SRC_WIN)
352 type = CMD_WIN;
353 else
354 type = cur_win->generic.type - 1;
355 while (type != cur_win->generic.type && (prev == NULL))
356 {
357 if (tui_win_list[type]
358 && tui_win_list[type]->generic.is_visible)
359 prev = tui_win_list[type];
360 else
361 {
362 if (type == SRC_WIN)
363 type = CMD_WIN;
364 else
365 type--;
366 }
367 }
368
369 return prev;
370 }
371
372
373 /* Answer the window represented by name. */
374 struct tui_win_info *
375 tui_partial_win_by_name (char *name)
376 {
377 struct tui_win_info *win_info = (struct tui_win_info *) NULL;
378
379 if (name != (char *) NULL)
380 {
381 int i = 0;
382
383 while (i < MAX_MAJOR_WINDOWS && win_info == NULL)
384 {
385 if (tui_win_list[i] != 0)
386 {
387 const char *cur_name =
388 tui_win_name (&tui_win_list[i]->generic);
389
390 if (strlen (name) <= strlen (cur_name)
391 && startswith (cur_name, name))
392 win_info = tui_win_list[i];
393 }
394 i++;
395 }
396 }
397
398 return win_info;
399 }
400
401
402 /* Answer the name of the window. */
403 const char *
404 tui_win_name (const struct tui_gen_win_info *win_info)
405 {
406 char *name = (char *) NULL;
407
408 switch (win_info->type)
409 {
410 case SRC_WIN:
411 name = SRC_NAME;
412 break;
413 case CMD_WIN:
414 name = CMD_NAME;
415 break;
416 case DISASSEM_WIN:
417 name = DISASSEM_NAME;
418 break;
419 case DATA_WIN:
420 name = DATA_NAME;
421 break;
422 default:
423 name = "";
424 break;
425 }
426
427 return name;
428 }
429
430
431 void
432 tui_initialize_static_data (void)
433 {
434 tui_init_generic_part (tui_source_exec_info_win_ptr ());
435 tui_init_generic_part (tui_disassem_exec_info_win_ptr ());
436 tui_init_generic_part (tui_locator_win_info_ptr ());
437 }
438
439
440 struct tui_gen_win_info *
441 tui_alloc_generic_win_info (void)
442 {
443 struct tui_gen_win_info *win;
444
445 if ((win = XNEW (struct tui_gen_win_info)) != NULL)
446 tui_init_generic_part (win);
447
448 return win;
449 }
450
451
452 void
453 tui_init_generic_part (struct tui_gen_win_info *win)
454 {
455 win->width =
456 win->height =
457 win->origin.x =
458 win->origin.y =
459 win->viewport_height =
460 win->content_size =
461 win->last_visible_line = 0;
462 win->handle = (WINDOW *) NULL;
463 win->content = NULL;
464 win->content_in_use =
465 win->is_visible = FALSE;
466 win->title = 0;
467 }
468
469
470 /* init_content_element().
471 */
472 static void
473 init_content_element (struct tui_win_element *element,
474 enum tui_win_type type)
475 {
476 element->highlight = FALSE;
477 switch (type)
478 {
479 case SRC_WIN:
480 case DISASSEM_WIN:
481 element->which_element.source.line = (char *) NULL;
482 element->which_element.source.line_or_addr.loa = LOA_LINE;
483 element->which_element.source.line_or_addr.u.line_no = 0;
484 element->which_element.source.is_exec_point = FALSE;
485 element->which_element.source.has_break = FALSE;
486 break;
487 case DATA_WIN:
488 tui_init_generic_part (&element->which_element.data_window);
489 element->which_element.data_window.type = DATA_ITEM_WIN;
490 element->which_element.data_window.content =
491 tui_alloc_content (1, DATA_ITEM_WIN);
492 element->which_element.data_window.content_size = 1;
493 break;
494 case CMD_WIN:
495 element->which_element.command.line = (char *) NULL;
496 break;
497 case DATA_ITEM_WIN:
498 element->which_element.data.name = (char *) NULL;
499 element->which_element.data.type = TUI_REGISTER;
500 element->which_element.data.item_no = UNDEFINED_ITEM;
501 element->which_element.data.value = NULL;
502 element->which_element.data.highlight = FALSE;
503 element->which_element.data.content = (char*) NULL;
504 break;
505 case LOCATOR_WIN:
506 element->which_element.locator.full_name[0] =
507 element->which_element.locator.proc_name[0] = (char) 0;
508 element->which_element.locator.line_no = 0;
509 element->which_element.locator.addr = 0;
510 break;
511 case EXEC_INFO_WIN:
512 memset(element->which_element.simple_string, ' ',
513 sizeof(element->which_element.simple_string));
514 break;
515 default:
516 break;
517 }
518 }
519
520 static void
521 init_win_info (struct tui_win_info *win_info)
522 {
523 tui_init_generic_part (&win_info->generic);
524 win_info->can_highlight =
525 win_info->is_highlighted = FALSE;
526 switch (win_info->generic.type)
527 {
528 case SRC_WIN:
529 case DISASSEM_WIN:
530 win_info->detail.source_info.execution_info
531 = (struct tui_gen_win_info *) NULL;
532 win_info->detail.source_info.has_locator = FALSE;
533 win_info->detail.source_info.horizontal_offset = 0;
534 win_info->detail.source_info.gdbarch = NULL;
535 win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
536 win_info->detail.source_info.start_line_or_addr.u.addr = 0;
537 win_info->detail.source_info.fullname = NULL;
538 break;
539 case DATA_WIN:
540 win_info->detail.data_display_info.data_content = (tui_win_content) NULL;
541 win_info->detail.data_display_info.data_content_count = 0;
542 win_info->detail.data_display_info.regs_content = (tui_win_content) NULL;
543 win_info->detail.data_display_info.regs_content_count = 0;
544 win_info->detail.data_display_info.regs_column_count = 1;
545 win_info->detail.data_display_info.display_regs = FALSE;
546 win_info->detail.data_display_info.current_group = 0;
547 break;
548 case CMD_WIN:
549 win_info->detail.command_info.cur_line = 0;
550 win_info->detail.command_info.curch = 0;
551 break;
552 default:
553 win_info->detail.opaque = NULL;
554 break;
555 }
556 }
557
558
559 struct tui_win_info *
560 tui_alloc_win_info (enum tui_win_type type)
561 {
562 struct tui_win_info *win_info;
563
564 win_info = XNEW (struct tui_win_info);
565 if (win_info != NULL)
566 {
567 win_info->generic.type = type;
568 init_win_info (win_info);
569 }
570
571 return win_info;
572 }
573
574
575 /* Allocates the content and elements in a block. */
576 tui_win_content
577 tui_alloc_content (int num_elements, enum tui_win_type type)
578 {
579 tui_win_content content;
580 char *element_block_ptr;
581 int i;
582
583 content = xmalloc (sizeof (struct tui_win_element *) *num_elements);
584 if (content != NULL)
585 {
586 /*
587 * All windows, except the data window, can allocate the
588 * elements in a chunk. The data window cannot because items
589 * can be added/removed from the data display by the user at any
590 * time.
591 */
592 if (type != DATA_WIN)
593 {
594 element_block_ptr =
595 xmalloc (sizeof (struct tui_win_element) * num_elements);
596 if (element_block_ptr != NULL)
597 {
598 for (i = 0; i < num_elements; i++)
599 {
600 content[i] = (struct tui_win_element *) element_block_ptr;
601 init_content_element (content[i], type);
602 element_block_ptr += sizeof (struct tui_win_element);
603 }
604 }
605 else
606 {
607 xfree (content);
608 content = (tui_win_content) NULL;
609 }
610 }
611 }
612
613 return content;
614 }
615
616
617 /* Adds the input number of elements to the windows's content. If no
618 content has been allocated yet, alloc_content() is called to do
619 this. The index of the first element added is returned, unless
620 there is a memory allocation error, in which case, (-1) is
621 returned. */
622 int
623 tui_add_content_elements (struct tui_gen_win_info *win_info,
624 int num_elements)
625 {
626 struct tui_win_element *element_ptr;
627 int i, index_start;
628
629 if (win_info->content == NULL)
630 {
631 win_info->content = tui_alloc_content (num_elements, win_info->type);
632 index_start = 0;
633 }
634 else
635 index_start = win_info->content_size;
636 if (win_info->content != NULL)
637 {
638 for (i = index_start; (i < num_elements + index_start); i++)
639 {
640 if ((element_ptr = XNEW (struct tui_win_element)) != NULL)
641 {
642 win_info->content[i] = (void *) element_ptr;
643 init_content_element (element_ptr, win_info->type);
644 win_info->content_size++;
645 }
646 else /* Things must be really hosed now! We ran out of
647 memory!? */
648 return (-1);
649 }
650 }
651
652 return index_start;
653 }
654
655
656 /* Delete all curses windows associated with win_info, leaving
657 everything else intact. */
658 void
659 tui_del_window (struct tui_win_info *win_info)
660 {
661 struct tui_gen_win_info *generic_win;
662
663 switch (win_info->generic.type)
664 {
665 case SRC_WIN:
666 case DISASSEM_WIN:
667 generic_win = tui_locator_win_info_ptr ();
668 if (generic_win != (struct tui_gen_win_info *) NULL)
669 {
670 tui_delete_win (generic_win->handle);
671 generic_win->handle = (WINDOW *) NULL;
672 generic_win->is_visible = FALSE;
673 }
674 if (win_info->detail.source_info.fullname)
675 {
676 xfree (win_info->detail.source_info.fullname);
677 win_info->detail.source_info.fullname = NULL;
678 }
679 generic_win = win_info->detail.source_info.execution_info;
680 if (generic_win != (struct tui_gen_win_info *) NULL)
681 {
682 tui_delete_win (generic_win->handle);
683 generic_win->handle = (WINDOW *) NULL;
684 generic_win->is_visible = FALSE;
685 }
686 break;
687 case DATA_WIN:
688 if (win_info->generic.content != NULL)
689 {
690 tui_del_data_windows (win_info->detail.data_display_info.regs_content,
691 win_info->detail.data_display_info.regs_content_count);
692 tui_del_data_windows (win_info->detail.data_display_info.data_content,
693 win_info->detail.data_display_info.data_content_count);
694 }
695 break;
696 default:
697 break;
698 }
699 if (win_info->generic.handle != (WINDOW *) NULL)
700 {
701 tui_delete_win (win_info->generic.handle);
702 win_info->generic.handle = (WINDOW *) NULL;
703 win_info->generic.is_visible = FALSE;
704 }
705 }
706
707
708 void
709 tui_free_window (struct tui_win_info *win_info)
710 {
711 struct tui_gen_win_info *generic_win;
712
713 switch (win_info->generic.type)
714 {
715 case SRC_WIN:
716 case DISASSEM_WIN:
717 if (win_info->detail.source_info.fullname)
718 {
719 xfree (win_info->detail.source_info.fullname);
720 win_info->detail.source_info.fullname = NULL;
721 }
722 generic_win = win_info->detail.source_info.execution_info;
723 if (generic_win != (struct tui_gen_win_info *) NULL)
724 {
725 tui_delete_win (generic_win->handle);
726 generic_win->handle = (WINDOW *) NULL;
727 tui_free_win_content (generic_win);
728 }
729 break;
730 case DATA_WIN:
731 if (win_info->generic.content != NULL)
732 {
733 tui_free_data_content (win_info->detail.data_display_info.regs_content,
734 win_info->detail.data_display_info.regs_content_count);
735 win_info->detail.data_display_info.regs_content =
736 (tui_win_content) NULL;
737 win_info->detail.data_display_info.regs_content_count = 0;
738 tui_free_data_content (win_info->detail.data_display_info.data_content,
739 win_info->detail.data_display_info.data_content_count);
740 win_info->detail.data_display_info.data_content =
741 (tui_win_content) NULL;
742 win_info->detail.data_display_info.data_content_count = 0;
743 win_info->detail.data_display_info.regs_column_count = 1;
744 win_info->detail.data_display_info.display_regs = FALSE;
745 win_info->generic.content = NULL;
746 win_info->generic.content_size = 0;
747 }
748 break;
749 default:
750 break;
751 }
752 if (win_info->generic.handle != (WINDOW *) NULL)
753 {
754 tui_delete_win (win_info->generic.handle);
755 win_info->generic.handle = (WINDOW *) NULL;
756 tui_free_win_content (&win_info->generic);
757 }
758 if (win_info->generic.title)
759 xfree (win_info->generic.title);
760 xfree (win_info);
761 }
762
763
764 void
765 tui_free_all_source_wins_content (void)
766 {
767 int i;
768
769 for (i = 0; i < (tui_source_windows ())->count; i++)
770 {
771 struct tui_win_info *win_info = (tui_source_windows ())->list[i];
772
773 if (win_info != NULL)
774 {
775 tui_free_win_content (&(win_info->generic));
776 tui_free_win_content (win_info->detail.source_info.execution_info);
777 }
778 }
779 }
780
781
782 void
783 tui_free_win_content (struct tui_gen_win_info *win_info)
784 {
785 if (win_info->content != NULL)
786 {
787 free_content ((tui_win_content) win_info->content,
788 win_info->content_size,
789 win_info->type);
790 win_info->content = NULL;
791 }
792 win_info->content_size = 0;
793 }
794
795
796 void
797 tui_del_data_windows (tui_win_content content,
798 int content_size)
799 {
800 int i;
801
802 /* Remember that data window content elements are of type struct
803 tui_gen_win_info *, each of which whose single element is a data
804 element. */
805 for (i = 0; i < content_size; i++)
806 {
807 struct tui_gen_win_info *generic_win
808 = &content[i]->which_element.data_window;
809
810 if (generic_win != (struct tui_gen_win_info *) NULL)
811 {
812 tui_delete_win (generic_win->handle);
813 generic_win->handle = (WINDOW *) NULL;
814 generic_win->is_visible = FALSE;
815 }
816 }
817 }
818
819
820 void
821 tui_free_data_content (tui_win_content content,
822 int content_size)
823 {
824 int i;
825
826 /* Remember that data window content elements are of type struct
827 tui_gen_win_info *, each of which whose single element is a data
828 element. */
829 for (i = 0; i < content_size; i++)
830 {
831 struct tui_gen_win_info *generic_win
832 = &content[i]->which_element.data_window;
833
834 if (generic_win != (struct tui_gen_win_info *) NULL)
835 {
836 tui_delete_win (generic_win->handle);
837 generic_win->handle = (WINDOW *) NULL;
838 tui_free_win_content (generic_win);
839 }
840 }
841 free_content (content,
842 content_size,
843 DATA_WIN);
844 }
845
846
847 /**********************************
848 ** LOCAL STATIC FUNCTIONS **
849 **********************************/
850
851
852 static void
853 free_content (tui_win_content content,
854 int content_size,
855 enum tui_win_type win_type)
856 {
857 if (content != (tui_win_content) NULL)
858 {
859 free_content_elements (content, content_size, win_type);
860 xfree (content);
861 }
862 }
863
864
865 /* free_content_elements().
866 */
867 static void
868 free_content_elements (tui_win_content content,
869 int content_size,
870 enum tui_win_type type)
871 {
872 if (content != (tui_win_content) NULL)
873 {
874 int i;
875
876 if (type == SRC_WIN || type == DISASSEM_WIN)
877 {
878 /* Free whole source block. */
879 xfree (content[0]->which_element.source.line);
880 }
881 else
882 {
883 for (i = 0; i < content_size; i++)
884 {
885 struct tui_win_element *element;
886
887 element = content[i];
888 if (element != (struct tui_win_element *) NULL)
889 {
890 switch (type)
891 {
892 case DATA_WIN:
893 xfree (element);
894 break;
895 case DATA_ITEM_WIN:
896 /* Note that data elements are not allocated in
897 a single block, but individually, as
898 needed. */
899 if (element->which_element.data.type != TUI_REGISTER)
900 xfree ((void *)element->which_element.data.name);
901 xfree (element->which_element.data.value);
902 xfree (element->which_element.data.content);
903 xfree (element);
904 break;
905 case CMD_WIN:
906 xfree (element->which_element.command.line);
907 break;
908 default:
909 break;
910 }
911 }
912 }
913 }
914 if (type != DATA_WIN && type != DATA_ITEM_WIN)
915 xfree (content[0]); /* Free the element block. */
916 }
917 }
This page took 0.048041 seconds and 5 git commands to generate.