gdb: Use NULL not 0 in a tui function.
[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 char *cur_name = 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 char *
403 tui_win_name (struct tui_gen_win_info *win_info)
404 {
405 char *name = (char *) 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;
443
444 if ((win = XNEW (struct tui_gen_win_info)) != 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 = (WINDOW *) 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 = (char *) 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 = (char *) NULL;
495 break;
496 case DATA_ITEM_WIN:
497 element->which_element.data.name = (char *) 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 = (char*) 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 win_info->detail.command_info.cur_line = 0;
549 win_info->detail.command_info.curch = 0;
550 break;
551 default:
552 win_info->detail.opaque = NULL;
553 break;
554 }
555 }
556
557
558 struct tui_win_info *
559 tui_alloc_win_info (enum tui_win_type type)
560 {
561 struct tui_win_info *win_info;
562
563 win_info = XNEW (struct tui_win_info);
564 if (win_info != NULL)
565 {
566 win_info->generic.type = type;
567 init_win_info (win_info);
568 }
569
570 return win_info;
571 }
572
573
574 /* Allocates the content and elements in a block. */
575 tui_win_content
576 tui_alloc_content (int num_elements, enum tui_win_type type)
577 {
578 tui_win_content content;
579 char *element_block_ptr;
580 int i;
581
582 content = xmalloc (sizeof (struct tui_win_element *) *num_elements);
583 if (content != NULL)
584 {
585 /*
586 * All windows, except the data window, can allocate the
587 * elements in a chunk. The data window cannot because items
588 * can be added/removed from the data display by the user at any
589 * time.
590 */
591 if (type != DATA_WIN)
592 {
593 element_block_ptr =
594 xmalloc (sizeof (struct tui_win_element) * num_elements);
595 if (element_block_ptr != NULL)
596 {
597 for (i = 0; i < num_elements; i++)
598 {
599 content[i] = (struct tui_win_element *) element_block_ptr;
600 init_content_element (content[i], type);
601 element_block_ptr += sizeof (struct tui_win_element);
602 }
603 }
604 else
605 {
606 xfree (content);
607 content = (tui_win_content) NULL;
608 }
609 }
610 }
611
612 return content;
613 }
614
615
616 /* Adds the input number of elements to the windows's content. If no
617 content has been allocated yet, alloc_content() is called to do
618 this. The index of the first element added is returned, unless
619 there is a memory allocation error, in which case, (-1) is
620 returned. */
621 int
622 tui_add_content_elements (struct tui_gen_win_info *win_info,
623 int num_elements)
624 {
625 struct tui_win_element *element_ptr;
626 int i, index_start;
627
628 if (win_info->content == NULL)
629 {
630 win_info->content = tui_alloc_content (num_elements, win_info->type);
631 index_start = 0;
632 }
633 else
634 index_start = win_info->content_size;
635 if (win_info->content != NULL)
636 {
637 for (i = index_start; (i < num_elements + index_start); i++)
638 {
639 if ((element_ptr = XNEW (struct tui_win_element)) != NULL)
640 {
641 win_info->content[i] = (void *) element_ptr;
642 init_content_element (element_ptr, win_info->type);
643 win_info->content_size++;
644 }
645 else /* Things must be really hosed now! We ran out of
646 memory!? */
647 return (-1);
648 }
649 }
650
651 return index_start;
652 }
653
654
655 /* Delete all curses windows associated with win_info, leaving
656 everything else intact. */
657 void
658 tui_del_window (struct tui_win_info *win_info)
659 {
660 struct tui_gen_win_info *generic_win;
661
662 switch (win_info->generic.type)
663 {
664 case SRC_WIN:
665 case DISASSEM_WIN:
666 generic_win = tui_locator_win_info_ptr ();
667 if (generic_win != (struct tui_gen_win_info *) NULL)
668 {
669 tui_delete_win (generic_win->handle);
670 generic_win->handle = (WINDOW *) NULL;
671 generic_win->is_visible = FALSE;
672 }
673 if (win_info->detail.source_info.fullname)
674 {
675 xfree (win_info->detail.source_info.fullname);
676 win_info->detail.source_info.fullname = NULL;
677 }
678 generic_win = win_info->detail.source_info.execution_info;
679 if (generic_win != (struct tui_gen_win_info *) NULL)
680 {
681 tui_delete_win (generic_win->handle);
682 generic_win->handle = (WINDOW *) NULL;
683 generic_win->is_visible = FALSE;
684 }
685 break;
686 case DATA_WIN:
687 if (win_info->generic.content != NULL)
688 {
689 tui_del_data_windows (win_info->detail.data_display_info.regs_content,
690 win_info->detail.data_display_info.regs_content_count);
691 tui_del_data_windows (win_info->detail.data_display_info.data_content,
692 win_info->detail.data_display_info.data_content_count);
693 }
694 break;
695 default:
696 break;
697 }
698 if (win_info->generic.handle != (WINDOW *) NULL)
699 {
700 tui_delete_win (win_info->generic.handle);
701 win_info->generic.handle = (WINDOW *) NULL;
702 win_info->generic.is_visible = FALSE;
703 }
704 }
705
706
707 void
708 tui_free_window (struct tui_win_info *win_info)
709 {
710 struct tui_gen_win_info *generic_win;
711
712 switch (win_info->generic.type)
713 {
714 case SRC_WIN:
715 case DISASSEM_WIN:
716 if (win_info->detail.source_info.fullname)
717 {
718 xfree (win_info->detail.source_info.fullname);
719 win_info->detail.source_info.fullname = NULL;
720 }
721 generic_win = win_info->detail.source_info.execution_info;
722 if (generic_win != (struct tui_gen_win_info *) NULL)
723 {
724 tui_delete_win (generic_win->handle);
725 generic_win->handle = (WINDOW *) NULL;
726 tui_free_win_content (generic_win);
727 }
728 break;
729 case DATA_WIN:
730 if (win_info->generic.content != NULL)
731 {
732 tui_free_data_content (win_info->detail.data_display_info.regs_content,
733 win_info->detail.data_display_info.regs_content_count);
734 win_info->detail.data_display_info.regs_content =
735 (tui_win_content) NULL;
736 win_info->detail.data_display_info.regs_content_count = 0;
737 tui_free_data_content (win_info->detail.data_display_info.data_content,
738 win_info->detail.data_display_info.data_content_count);
739 win_info->detail.data_display_info.data_content =
740 (tui_win_content) NULL;
741 win_info->detail.data_display_info.data_content_count = 0;
742 win_info->detail.data_display_info.regs_column_count = 1;
743 win_info->detail.data_display_info.display_regs = FALSE;
744 win_info->generic.content = NULL;
745 win_info->generic.content_size = 0;
746 }
747 break;
748 default:
749 break;
750 }
751 if (win_info->generic.handle != (WINDOW *) NULL)
752 {
753 tui_delete_win (win_info->generic.handle);
754 win_info->generic.handle = (WINDOW *) NULL;
755 tui_free_win_content (&win_info->generic);
756 }
757 if (win_info->generic.title)
758 xfree (win_info->generic.title);
759 xfree (win_info);
760 }
761
762
763 void
764 tui_free_all_source_wins_content (void)
765 {
766 int i;
767
768 for (i = 0; i < (tui_source_windows ())->count; i++)
769 {
770 struct tui_win_info *win_info = (tui_source_windows ())->list[i];
771
772 if (win_info != NULL)
773 {
774 tui_free_win_content (&(win_info->generic));
775 tui_free_win_content (win_info->detail.source_info.execution_info);
776 }
777 }
778 }
779
780
781 void
782 tui_free_win_content (struct tui_gen_win_info *win_info)
783 {
784 if (win_info->content != NULL)
785 {
786 free_content ((tui_win_content) win_info->content,
787 win_info->content_size,
788 win_info->type);
789 win_info->content = NULL;
790 }
791 win_info->content_size = 0;
792 }
793
794
795 void
796 tui_del_data_windows (tui_win_content content,
797 int content_size)
798 {
799 int i;
800
801 /* Remember that data window content elements are of type struct
802 tui_gen_win_info *, each of which whose single element is a data
803 element. */
804 for (i = 0; i < content_size; i++)
805 {
806 struct tui_gen_win_info *generic_win
807 = &content[i]->which_element.data_window;
808
809 if (generic_win != (struct tui_gen_win_info *) NULL)
810 {
811 tui_delete_win (generic_win->handle);
812 generic_win->handle = (WINDOW *) NULL;
813 generic_win->is_visible = FALSE;
814 }
815 }
816 }
817
818
819 void
820 tui_free_data_content (tui_win_content content,
821 int content_size)
822 {
823 int i;
824
825 /* Remember that data window content elements are of type struct
826 tui_gen_win_info *, each of which whose single element is a data
827 element. */
828 for (i = 0; i < content_size; i++)
829 {
830 struct tui_gen_win_info *generic_win
831 = &content[i]->which_element.data_window;
832
833 if (generic_win != (struct tui_gen_win_info *) NULL)
834 {
835 tui_delete_win (generic_win->handle);
836 generic_win->handle = (WINDOW *) NULL;
837 tui_free_win_content (generic_win);
838 }
839 }
840 free_content (content,
841 content_size,
842 DATA_WIN);
843 }
844
845
846 /**********************************
847 ** LOCAL STATIC FUNCTIONS **
848 **********************************/
849
850
851 static void
852 free_content (tui_win_content content,
853 int content_size,
854 enum tui_win_type win_type)
855 {
856 if (content != (tui_win_content) NULL)
857 {
858 free_content_elements (content, content_size, win_type);
859 xfree (content);
860 }
861 }
862
863
864 /* free_content_elements().
865 */
866 static void
867 free_content_elements (tui_win_content content,
868 int content_size,
869 enum tui_win_type type)
870 {
871 if (content != (tui_win_content) NULL)
872 {
873 int i;
874
875 if (type == SRC_WIN || type == DISASSEM_WIN)
876 {
877 /* Free whole source block. */
878 xfree (content[0]->which_element.source.line);
879 }
880 else
881 {
882 for (i = 0; i < content_size; i++)
883 {
884 struct tui_win_element *element;
885
886 element = content[i];
887 if (element != (struct tui_win_element *) NULL)
888 {
889 switch (type)
890 {
891 case DATA_WIN:
892 xfree (element);
893 break;
894 case DATA_ITEM_WIN:
895 /* Note that data elements are not allocated in
896 a single block, but individually, as
897 needed. */
898 if (element->which_element.data.type != TUI_REGISTER)
899 xfree ((void *)element->which_element.data.name);
900 xfree (element->which_element.data.value);
901 xfree (element->which_element.data.content);
902 xfree (element);
903 break;
904 case CMD_WIN:
905 xfree (element->which_element.command.line);
906 break;
907 default:
908 break;
909 }
910 }
911 }
912 }
913 if (type != DATA_WIN && type != DATA_ITEM_WIN)
914 xfree (content[0]); /* Free the element block. */
915 }
916 }
This page took 0.047833 seconds and 4 git commands to generate.