Introduce set_highlight method
[deliverable/binutils-gdb.git] / gdb / tui / tui-data.c
CommitLineData
f377b406 1/* TUI data manipulation routines.
f33c6cbf 2
42a4f53d 3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
f33c6cbf 4
f377b406
SC
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
f377b406
SC
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
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 21
96ec9981
DJ
22#include "defs.h"
23#include "symtab.h"
d7b2e967
AC
24#include "tui/tui.h"
25#include "tui/tui-data.h"
26#include "tui/tui-wingeneral.h"
6a83354a 27#include "gdb_curses.h"
4e8f7a8b 28
c906108c
SS
29/****************************
30** GLOBAL DECLARATIONS
31****************************/
7fa29be9 32struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
c906108c 33
c906108c
SS
34/***************************
35** Private data
36****************************/
6ba8e26f
AC
37static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
38static int term_height, term_width;
2a8854a7 39static struct tui_gen_win_info _locator;
6ba8e26f 40static struct tui_gen_win_info exec_info[2];
ad54d15b 41static std::vector<tui_source_window_base *> source_windows;
e65b5245 42static struct tui_win_info *win_with_focus = NULL;
08ef48c5
MS
43static struct tui_layout_def layout_def = {
44 SRC_WIN, /* DISPLAY_MODE */
7bd0be3a 45 FALSE}; /* SPLIT */
08ef48c5 46
6ba8e26f 47static int win_resized = FALSE;
c906108c
SS
48
49
50/*********************************
51** Static function forward decls
52**********************************/
08ef48c5
MS
53static void free_content (tui_win_content,
54 int,
55 enum tui_win_type);
56static void free_content_elements (tui_win_content,
57 int,
58 enum tui_win_type);
c906108c
SS
59
60
61
62/*********************************
63** PUBLIC FUNCTIONS
64**********************************/
65
6d012f14
AC
66int
67tui_win_is_auxillary (enum tui_win_type win_type)
68{
69 return (win_type > MAX_MAJOR_WINDOWS);
70}
71
c906108c
SS
72/******************************************
73** ACCESSORS & MUTATORS FOR PRIVATE DATA
74******************************************/
75
1cc6d956 76/* Answer a whether the terminal window has been resized or not. */
c906108c 77int
dd1abb8c 78tui_win_resized (void)
c906108c 79{
6ba8e26f 80 return win_resized;
dd1abb8c 81}
c906108c
SS
82
83
1cc6d956 84/* Set a whether the terminal window has been resized or not. */
c906108c 85void
dd1abb8c 86tui_set_win_resized_to (int resized)
c906108c 87{
6ba8e26f 88 win_resized = resized;
dd1abb8c 89}
c906108c
SS
90
91
1cc6d956 92/* Answer a pointer to the current layout definition. */
2a8854a7 93struct tui_layout_def *
dd1abb8c 94tui_layout_def (void)
c906108c 95{
6ba8e26f 96 return &layout_def;
dd1abb8c 97}
c906108c
SS
98
99
1cc6d956 100/* Answer the window with the logical focus. */
2a8854a7 101struct tui_win_info *
dd1abb8c 102tui_win_with_focus (void)
c906108c 103{
6ba8e26f 104 return win_with_focus;
dd1abb8c 105}
c906108c
SS
106
107
1cc6d956 108/* Set the window that has the logical focus. */
c906108c 109void
5b6fe301 110tui_set_win_with_focus (struct tui_win_info *win_info)
c906108c 111{
6ba8e26f 112 win_with_focus = win_info;
dd1abb8c 113}
c906108c
SS
114
115
6ba8e26f
AC
116/* Accessor for the current source window. Usually there is only one
117 source window (either source or disassembly), but both can be
118 displayed at the same time. */
ad54d15b 119std::vector<tui_source_window_base *> &
b4eb2452 120tui_source_windows ()
c906108c 121{
b4eb2452 122 return source_windows;
dd1abb8c 123}
c906108c
SS
124
125
dd1abb8c
AC
126/* Clear the list of source windows. Usually there is only one source
127 window (either source or disassembly), but both can be displayed at
128 the same time. */
c906108c 129void
b4eb2452 130tui_clear_source_windows ()
c906108c 131{
b4eb2452 132 source_windows.clear ();
dd1abb8c 133}
c906108c
SS
134
135
1cc6d956 136/* Clear the pertinant detail in the source windows. */
c906108c 137void
b4eb2452 138tui_clear_source_windows_detail ()
c906108c 139{
ad54d15b 140 for (tui_source_window_base *win : tui_source_windows ())
7778b912 141 win->clear_detail ();
dd1abb8c 142}
c906108c
SS
143
144
dd1abb8c
AC
145/* Add a window to the list of source windows. Usually there is only
146 one source window (either source or disassembly), but both can be
147 displayed at the same time. */
c906108c 148void
ad54d15b 149tui_add_to_source_windows (struct tui_source_window_base *win_info)
c906108c 150{
b4eb2452
TT
151 if (source_windows.size () < 2)
152 source_windows.push_back (win_info);
dd1abb8c 153}
c906108c 154
8761a91b
TT
155/* See tui-data.h. */
156
157void
5cf82909 158tui_source_window_base::clear_detail ()
8761a91b 159{
e6e41501
TT
160 gdbarch = NULL;
161 start_line_or_addr.loa = LOA_ADDRESS;
162 start_line_or_addr.u.addr = 0;
163 horizontal_offset = 0;
8761a91b
TT
164}
165
166/* See tui-data.h. */
167
168void
169tui_cmd_window::clear_detail ()
170{
171 wmove (generic.handle, 0, 0);
172}
173
174/* See tui-data.h. */
175
176void
177tui_data_window::clear_detail ()
178{
238eb706
TT
179 data_content = NULL;
180 data_content_count = 0;
181 regs_content = NULL;
182 regs_content_count = 0;
183 regs_column_count = 1;
ceb13a13 184 display_regs = false;
8761a91b 185}
c906108c 186
6ba8e26f 187/* Accessor for the source execution info ptr. */
2a8854a7 188struct tui_gen_win_info *
dd1abb8c 189tui_source_exec_info_win_ptr (void)
c906108c 190{
6ba8e26f
AC
191 return &exec_info[0];
192}
c906108c
SS
193
194
6ba8e26f 195/* Accessor for the disassem execution info ptr. */
2a8854a7 196struct tui_gen_win_info *
dd1abb8c 197tui_disassem_exec_info_win_ptr (void)
c906108c 198{
6ba8e26f
AC
199 return &exec_info[1];
200}
c906108c
SS
201
202
dd1abb8c
AC
203/* Accessor for the locator win info. Answers a pointer to the static
204 locator win info struct. */
2a8854a7 205struct tui_gen_win_info *
dd1abb8c 206tui_locator_win_info_ptr (void)
c906108c
SS
207{
208 return &_locator;
2a8854a7 209}
c906108c
SS
210
211
6ba8e26f 212/* Accessor for the term_height. */
c906108c 213int
dd1abb8c 214tui_term_height (void)
c906108c 215{
6ba8e26f 216 return term_height;
dd1abb8c 217}
c906108c
SS
218
219
1cc6d956 220/* Mutator for the term height. */
c906108c 221void
dd1abb8c 222tui_set_term_height_to (int h)
c906108c 223{
6ba8e26f 224 term_height = h;
dd1abb8c 225}
c906108c
SS
226
227
1cc6d956 228/* Accessor for the term_width. */
c906108c 229int
dd1abb8c 230tui_term_width (void)
c906108c 231{
6ba8e26f 232 return term_width;
dd1abb8c 233}
c906108c
SS
234
235
6ba8e26f 236/* Mutator for the term_width. */
c906108c 237void
dd1abb8c 238tui_set_term_width_to (int w)
c906108c 239{
6ba8e26f 240 term_width = w;
dd1abb8c 241}
c906108c
SS
242
243
1cc6d956 244/* Accessor for the current layout. */
2a8854a7 245enum tui_layout_type
dd1abb8c 246tui_current_layout (void)
c906108c 247{
6ba8e26f 248 return current_layout;
dd1abb8c 249}
c906108c
SS
250
251
dd1abb8c 252/* Mutator for the current layout. */
c906108c 253void
6ba8e26f 254tui_set_current_layout_to (enum tui_layout_type new_layout)
c906108c 255{
6ba8e26f 256 current_layout = new_layout;
dd1abb8c 257}
c906108c
SS
258
259
c906108c
SS
260/*****************************
261** OTHER PUBLIC FUNCTIONS
262*****************************/
263
264
dd1abb8c
AC
265/* Answer the next window in the list, cycling back to the top if
266 necessary. */
2a8854a7 267struct tui_win_info *
5b6fe301 268tui_next_win (struct tui_win_info *cur_win)
c906108c 269{
570dc176 270 int type = cur_win->generic.type;
e65b5245 271 struct tui_win_info *next_win = NULL;
c906108c 272
6ba8e26f 273 if (cur_win->generic.type == CMD_WIN)
c906108c
SS
274 type = SRC_WIN;
275 else
6ba8e26f
AC
276 type = cur_win->generic.type + 1;
277 while (type != cur_win->generic.type && (next_win == NULL))
c906108c 278 {
e5908723
MS
279 if (tui_win_list[type]
280 && tui_win_list[type]->generic.is_visible)
6ba8e26f 281 next_win = tui_win_list[type];
c906108c
SS
282 else
283 {
284 if (type == CMD_WIN)
285 type = SRC_WIN;
286 else
287 type++;
288 }
289 }
290
6ba8e26f
AC
291 return next_win;
292}
c906108c
SS
293
294
dd1abb8c
AC
295/* Answer the prev window in the list, cycling back to the bottom if
296 necessary. */
2a8854a7 297struct tui_win_info *
5b6fe301 298tui_prev_win (struct tui_win_info *cur_win)
c906108c 299{
570dc176 300 int type = cur_win->generic.type;
e65b5245 301 struct tui_win_info *prev = NULL;
c906108c 302
6ba8e26f 303 if (cur_win->generic.type == SRC_WIN)
c906108c
SS
304 type = CMD_WIN;
305 else
6ba8e26f
AC
306 type = cur_win->generic.type - 1;
307 while (type != cur_win->generic.type && (prev == NULL))
c906108c 308 {
37715c4c
TJB
309 if (tui_win_list[type]
310 && tui_win_list[type]->generic.is_visible)
6d012f14 311 prev = tui_win_list[type];
c906108c
SS
312 else
313 {
314 if (type == SRC_WIN)
315 type = CMD_WIN;
316 else
317 type--;
318 }
319 }
320
321 return prev;
cb50eddd 322}
c906108c
SS
323
324
1cc6d956 325/* Answer the window represented by name. */
2a8854a7 326struct tui_win_info *
a121b7c1 327tui_partial_win_by_name (const char *name)
c906108c 328{
e65b5245 329 struct tui_win_info *win_info = NULL;
c906108c 330
63a33118 331 if (name != NULL)
c906108c
SS
332 {
333 int i = 0;
334
6d012f14 335 while (i < MAX_MAJOR_WINDOWS && win_info == NULL)
c906108c 336 {
6d012f14 337 if (tui_win_list[i] != 0)
a4b99e53 338 {
f41cbf58
AB
339 const char *cur_name =
340 tui_win_name (&tui_win_list[i]->generic);
1c5313c5 341
e5908723 342 if (strlen (name) <= strlen (cur_name)
61012eef 343 && startswith (cur_name, name))
6d012f14 344 win_info = tui_win_list[i];
a4b99e53 345 }
c906108c
SS
346 i++;
347 }
348 }
349
6d012f14 350 return win_info;
6ba8e26f 351}
c906108c
SS
352
353
6ba8e26f 354/* Answer the name of the window. */
f41cbf58
AB
355const char *
356tui_win_name (const struct tui_gen_win_info *win_info)
c906108c 357{
136765ea 358 const char *name = NULL;
c906108c 359
6d012f14 360 switch (win_info->type)
c906108c
SS
361 {
362 case SRC_WIN:
363 name = SRC_NAME;
364 break;
365 case CMD_WIN:
366 name = CMD_NAME;
367 break;
368 case DISASSEM_WIN:
369 name = DISASSEM_NAME;
370 break;
371 case DATA_WIN:
372 name = DATA_NAME;
373 break;
374 default:
375 name = "";
376 break;
377 }
378
379 return name;
6ba8e26f 380}
c906108c
SS
381
382
c906108c 383void
dd1abb8c 384tui_initialize_static_data (void)
c906108c 385{
dd1abb8c
AC
386 tui_init_generic_part (tui_source_exec_info_win_ptr ());
387 tui_init_generic_part (tui_disassem_exec_info_win_ptr ());
388 tui_init_generic_part (tui_locator_win_info_ptr ());
389}
c906108c
SS
390
391
2a8854a7 392struct tui_gen_win_info *
dd1abb8c 393tui_alloc_generic_win_info (void)
c906108c 394{
8d749320 395 struct tui_gen_win_info *win = XNEW (struct tui_gen_win_info);
c906108c 396
730ead81 397 tui_init_generic_part (win);
c906108c
SS
398
399 return win;
6ba8e26f 400}
c906108c
SS
401
402
c906108c 403void
5b6fe301 404tui_init_generic_part (struct tui_gen_win_info *win)
c906108c
SS
405{
406 win->width =
407 win->height =
408 win->origin.x =
409 win->origin.y =
6d012f14
AC
410 win->viewport_height =
411 win->content_size =
412 win->last_visible_line = 0;
e65b5245 413 win->handle = NULL;
22940a24 414 win->content = NULL;
56122977
TT
415 win->content_in_use = FALSE;
416 win->is_visible = false;
bc6b7f04
SC
417 win->title = 0;
418}
c906108c
SS
419
420
ef5eab5a 421/* init_content_element().
c5aa993b 422 */
2c0b251b 423static void
08ef48c5
MS
424init_content_element (struct tui_win_element *element,
425 enum tui_win_type type)
c906108c 426{
c906108c
SS
427 switch (type)
428 {
429 case SRC_WIN:
430 case DISASSEM_WIN:
e65b5245 431 element->which_element.source.line = NULL;
362c05fe
AS
432 element->which_element.source.line_or_addr.loa = LOA_LINE;
433 element->which_element.source.line_or_addr.u.line_no = 0;
6d012f14
AC
434 element->which_element.source.is_exec_point = FALSE;
435 element->which_element.source.has_break = FALSE;
c906108c
SS
436 break;
437 case DATA_WIN:
6d012f14
AC
438 tui_init_generic_part (&element->which_element.data_window);
439 element->which_element.data_window.type = DATA_ITEM_WIN;
63ed8182
PP
440 element->which_element.data_window.content =
441 tui_alloc_content (1, DATA_ITEM_WIN);
442 element->which_element.data_window.content_size = 1;
c906108c
SS
443 break;
444 case CMD_WIN:
e65b5245 445 element->which_element.command.line = NULL;
c906108c
SS
446 break;
447 case DATA_ITEM_WIN:
e65b5245 448 element->which_element.data.name = NULL;
6d012f14
AC
449 element->which_element.data.type = TUI_REGISTER;
450 element->which_element.data.item_no = UNDEFINED_ITEM;
451 element->which_element.data.value = NULL;
452 element->which_element.data.highlight = FALSE;
e65b5245 453 element->which_element.data.content = NULL;
c906108c
SS
454 break;
455 case LOCATOR_WIN:
56d397a3 456 element->which_element.locator.full_name[0] =
6d012f14
AC
457 element->which_element.locator.proc_name[0] = (char) 0;
458 element->which_element.locator.line_no = 0;
459 element->which_element.locator.addr = 0;
c906108c
SS
460 break;
461 case EXEC_INFO_WIN:
6d012f14
AC
462 memset(element->which_element.simple_string, ' ',
463 sizeof(element->which_element.simple_string));
c906108c
SS
464 break;
465 default:
466 break;
467 }
6ba8e26f 468}
c906108c 469
33b906ab 470tui_win_info::tui_win_info (enum tui_win_type type)
c906108c 471{
33b906ab
TT
472 generic.type = type;
473 tui_init_generic_part (&generic);
6ba8e26f 474}
c906108c 475
5cf82909 476tui_source_window_base::tui_source_window_base (enum tui_win_type type)
33b906ab
TT
477 : tui_win_info (type)
478{
479 gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
e6e41501
TT
480 start_line_or_addr.loa = LOA_ADDRESS;
481 start_line_or_addr.u.addr = 0;
33b906ab
TT
482}
483
2a8854a7 484struct tui_win_info *
22940a24 485tui_alloc_win_info (enum tui_win_type type)
c906108c 486{
33b906ab
TT
487 switch (type)
488 {
489 case SRC_WIN:
5cf82909
TT
490 return new tui_source_window ();
491
33b906ab 492 case DISASSEM_WIN:
5cf82909 493 return new tui_disasm_window ();
c906108c 494
33b906ab
TT
495 case DATA_WIN:
496 return new tui_data_window ();
c906108c 497
33b906ab
TT
498 case CMD_WIN:
499 return new tui_cmd_window ();
500 }
501
502 gdb_assert_not_reached (_("Unhandled window type"));
6ba8e26f 503}
c906108c
SS
504
505
6ba8e26f 506/* Allocates the content and elements in a block. */
2a8854a7 507tui_win_content
6ba8e26f 508tui_alloc_content (int num_elements, enum tui_win_type type)
c906108c 509{
c0645fb5 510 tui_win_content content;
7acd011b 511 struct tui_win_element *element_block_ptr;
c906108c
SS
512 int i;
513
8d749320 514 content = XNEWVEC (struct tui_win_element *, num_elements);
7acd011b
SM
515
516 /*
517 * All windows, except the data window, can allocate the
518 * elements in a chunk. The data window cannot because items
519 * can be added/removed from the data display by the user at any
520 * time.
521 */
522 if (type != DATA_WIN)
c0645fb5 523 {
7acd011b
SM
524 element_block_ptr = XNEWVEC (struct tui_win_element, num_elements);
525 for (i = 0; i < num_elements; i++)
c906108c 526 {
7acd011b
SM
527 content[i] = element_block_ptr;
528 init_content_element (content[i], type);
529 element_block_ptr++;
c906108c
SS
530 }
531 }
532
533 return content;
6ba8e26f 534}
c906108c
SS
535
536
dd1abb8c 537/* Adds the input number of elements to the windows's content. If no
6ba8e26f 538 content has been allocated yet, alloc_content() is called to do
dd1abb8c
AC
539 this. The index of the first element added is returned, unless
540 there is a memory allocation error, in which case, (-1) is
541 returned. */
c906108c 542int
08ef48c5
MS
543tui_add_content_elements (struct tui_gen_win_info *win_info,
544 int num_elements)
c906108c 545{
5b6fe301 546 struct tui_win_element *element_ptr;
6ba8e26f 547 int i, index_start;
c906108c 548
6d012f14 549 if (win_info->content == NULL)
c906108c 550 {
63ed8182 551 win_info->content = tui_alloc_content (num_elements, win_info->type);
6ba8e26f 552 index_start = 0;
c906108c
SS
553 }
554 else
6ba8e26f 555 index_start = win_info->content_size;
6d012f14 556 if (win_info->content != NULL)
c906108c 557 {
6ba8e26f 558 for (i = index_start; (i < num_elements + index_start); i++)
c906108c 559 {
8d749320 560 element_ptr = XNEW (struct tui_win_element);
730ead81
TT
561 win_info->content[i] = element_ptr;
562 init_content_element (element_ptr, win_info->type);
563 win_info->content_size++;
c906108c
SS
564 }
565 }
566
6ba8e26f
AC
567 return index_start;
568}
c906108c 569
5cf82909 570tui_source_window_base::~tui_source_window_base ()
c906108c 571{
e6e41501
TT
572 xfree (fullname);
573 struct tui_gen_win_info *generic_win = execution_info;
ee1d42d6
TT
574 if (generic_win != NULL)
575 {
576 tui_delete_win (generic_win->handle);
577 generic_win->handle = NULL;
578 tui_free_win_content (generic_win);
579 }
580}
c906108c 581
ee1d42d6
TT
582tui_data_window::~tui_data_window ()
583{
584 if (generic.content != NULL)
c906108c 585 {
238eb706
TT
586 tui_free_data_content (regs_content, regs_content_count);
587 regs_content = NULL;
588 regs_content_count = 0;
589 tui_free_data_content (data_content, data_content_count);
590 data_content = NULL;
591 data_content_count = 0;
592 regs_column_count = 1;
ceb13a13 593 display_regs = false;
ee1d42d6
TT
594 generic.content = NULL;
595 generic.content_size = 0;
c906108c 596 }
ee1d42d6
TT
597}
598
599tui_win_info::~tui_win_info ()
600{
e7e11af4 601 if (generic.handle != NULL)
c906108c 602 {
e7e11af4
TT
603 tui_delete_win (generic.handle);
604 generic.handle = NULL;
605 tui_free_win_content (&generic);
c906108c 606 }
e7e11af4
TT
607 if (generic.title)
608 xfree (generic.title);
bc6b7f04 609}
c906108c
SS
610
611
c906108c 612void
b4eb2452 613tui_free_all_source_wins_content ()
c906108c 614{
ad54d15b 615 for (tui_source_window_base *win_info : tui_source_windows ())
c906108c 616 {
b4eb2452 617 tui_free_win_content (&(win_info->generic));
ad54d15b 618 tui_free_win_content (win_info->execution_info);
c906108c 619 }
dd1abb8c 620}
c906108c
SS
621
622
c906108c 623void
5b6fe301 624tui_free_win_content (struct tui_gen_win_info *win_info)
c906108c 625{
6d012f14 626 if (win_info->content != NULL)
c906108c 627 {
63a33118 628 free_content (win_info->content,
6d012f14
AC
629 win_info->content_size,
630 win_info->type);
631 win_info->content = NULL;
c906108c 632 }
6d012f14 633 win_info->content_size = 0;
6ba8e26f 634}
c906108c
SS
635
636
c906108c 637void
08ef48c5
MS
638tui_free_data_content (tui_win_content content,
639 int content_size)
c906108c
SS
640{
641 int i;
642
ef5eab5a
MS
643 /* Remember that data window content elements are of type struct
644 tui_gen_win_info *, each of which whose single element is a data
645 element. */
6ba8e26f 646 for (i = 0; i < content_size; i++)
c906108c 647 {
9a2b4c1b
MS
648 struct tui_gen_win_info *generic_win
649 = &content[i]->which_element.data_window;
c906108c 650
cafb3438 651 if (generic_win != NULL)
c906108c 652 {
6ba8e26f 653 tui_delete_win (generic_win->handle);
e65b5245 654 generic_win->handle = NULL;
6ba8e26f 655 tui_free_win_content (generic_win);
c906108c
SS
656 }
657 }
6ba8e26f 658 free_content (content,
08ef48c5
MS
659 content_size,
660 DATA_WIN);
6ba8e26f 661}
c906108c
SS
662
663
664/**********************************
665** LOCAL STATIC FUNCTIONS **
666**********************************/
667
668
c906108c 669static void
08ef48c5
MS
670free_content (tui_win_content content,
671 int content_size,
672 enum tui_win_type win_type)
c906108c 673{
d04b44a1 674 if (content != NULL)
c906108c 675 {
6ba8e26f 676 free_content_elements (content, content_size, win_type);
22940a24 677 xfree (content);
c906108c 678 }
6ba8e26f 679}
c906108c
SS
680
681
ef5eab5a 682/* free_content_elements().
c5aa993b 683 */
c906108c 684static void
08ef48c5
MS
685free_content_elements (tui_win_content content,
686 int content_size,
687 enum tui_win_type type)
c906108c 688{
d04b44a1 689 if (content != NULL)
c906108c
SS
690 {
691 int i;
692
62f29fda 693 if (type == DISASSEM_WIN)
c906108c 694 {
1cc6d956 695 /* Free whole source block. */
6d012f14 696 xfree (content[0]->which_element.source.line);
c906108c
SS
697 }
698 else
699 {
6ba8e26f 700 for (i = 0; i < content_size; i++)
c906108c 701 {
5b6fe301 702 struct tui_win_element *element;
c906108c
SS
703
704 element = content[i];
cafb3438 705 if (element != NULL)
c906108c
SS
706 {
707 switch (type)
708 {
62f29fda
TT
709 case SRC_WIN:
710 xfree (element->which_element.source.line);
711 break;
c906108c 712 case DATA_WIN:
22940a24 713 xfree (element);
c906108c
SS
714 break;
715 case DATA_ITEM_WIN:
ef5eab5a
MS
716 /* Note that data elements are not allocated in
717 a single block, but individually, as
718 needed. */
6d012f14
AC
719 if (element->which_element.data.type != TUI_REGISTER)
720 xfree ((void *)element->which_element.data.name);
721 xfree (element->which_element.data.value);
10f59415 722 xfree (element->which_element.data.content);
22940a24 723 xfree (element);
c906108c
SS
724 break;
725 case CMD_WIN:
6d012f14 726 xfree (element->which_element.command.line);
c906108c
SS
727 break;
728 default:
729 break;
730 }
731 }
732 }
733 }
734 if (type != DATA_WIN && type != DATA_ITEM_WIN)
1cc6d956 735 xfree (content[0]); /* Free the element block. */
c906108c 736 }
6ba8e26f 737}
This page took 2.076633 seconds and 4 git commands to generate.