2007-08-13 Michael Snyder <msnyder@access-company.com>
* tui/tui-winsource.c (tui_alloc_source_buffer): Clean up allocation.
This commit is contained in:
parent
f5b73fbba3
commit
81b7c67a8b
2 changed files with 20 additions and 23 deletions
|
@ -1,5 +1,7 @@
|
||||||
2007-08-13 Michael Snyder <msnyder@access-company.com>
|
2007-08-13 Michael Snyder <msnyder@access-company.com>
|
||||||
|
|
||||||
|
* tui/tui-winsource.c (tui_alloc_source_buffer): Clean up allocation.
|
||||||
|
|
||||||
* event-top.c (command_line_handler): Memory leak.
|
* event-top.c (command_line_handler): Memory leak.
|
||||||
|
|
||||||
* mi/mi-cmd-var.c (mi_cmd_var_set_format): Memory leak.
|
* mi/mi-cmd-var.c (mi_cmd_var_set_format): Memory leak.
|
||||||
|
|
|
@ -569,45 +569,40 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
|
||||||
{
|
{
|
||||||
char *src_line_buf;
|
char *src_line_buf;
|
||||||
int i, line_width, max_lines;
|
int i, line_width, max_lines;
|
||||||
enum tui_status ret = TUI_FAILURE;
|
|
||||||
|
|
||||||
max_lines = win_info->generic.height; /* less the highlight box */
|
max_lines = win_info->generic.height; /* less the highlight box */
|
||||||
line_width = win_info->generic.width - 1;
|
line_width = win_info->generic.width - 1;
|
||||||
/*
|
/*
|
||||||
** Allocate the buffer for the source lines. Do this only once since they
|
* Allocate the buffer for the source lines. Do this only once
|
||||||
** will be re-used for all source displays. The only other time this will
|
* since they will be re-used for all source displays. The only
|
||||||
** be done is when a window's size changes.
|
* other time this will be done is when a window's size changes.
|
||||||
*/
|
*/
|
||||||
if (win_info->generic.content == NULL)
|
if (win_info->generic.content == NULL)
|
||||||
{
|
{
|
||||||
src_line_buf = (char *) xmalloc ((max_lines * line_width) * sizeof (char));
|
src_line_buf = (char *)
|
||||||
|
xmalloc ((max_lines * line_width) * sizeof (char));
|
||||||
if (src_line_buf == (char *) NULL)
|
if (src_line_buf == (char *) NULL)
|
||||||
fputs_unfiltered (
|
|
||||||
"Unable to Allocate Memory for Source or Disassembly Display.\n",
|
|
||||||
gdb_stderr);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* allocate the content list */
|
fputs_unfiltered ("Unable to Allocate Memory for Source or Disassembly Display.\n",
|
||||||
if ((win_info->generic.content =
|
gdb_stderr);
|
||||||
(void **) tui_alloc_content (max_lines, SRC_WIN)) == NULL)
|
return TUI_FAILURE;
|
||||||
{
|
}
|
||||||
xfree (src_line_buf);
|
/* allocate the content list */
|
||||||
src_line_buf = (char *) NULL;
|
if ((win_info->generic.content =
|
||||||
fputs_unfiltered (
|
(void **) tui_alloc_content (max_lines, SRC_WIN)) == NULL)
|
||||||
"Unable to Allocate Memory for Source or Disassembly Display.\n",
|
{
|
||||||
gdb_stderr);
|
xfree (src_line_buf);
|
||||||
}
|
fputs_unfiltered ("Unable to Allocate Memory for Source or Disassembly Display.\n",
|
||||||
|
gdb_stderr);
|
||||||
|
return TUI_FAILURE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < max_lines; i++)
|
for (i = 0; i < max_lines; i++)
|
||||||
((struct tui_win_element *)
|
((struct tui_win_element *)
|
||||||
win_info->generic.content[i])->which_element.source.line =
|
win_info->generic.content[i])->which_element.source.line =
|
||||||
src_line_buf + (line_width * i);
|
src_line_buf + (line_width * i);
|
||||||
ret = TUI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ret = TUI_SUCCESS;
|
|
||||||
|
|
||||||
return ret;
|
return TUI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue