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