mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-12-11 22:24:42 +00:00
tui: Simplify tui_alloc_content
I stumbled upon this while doing some cxx-conversion work. Since the x-family alloc functions throw on failure, it is useless to test their result for failure. The else branch of != NULL is basically dead code. I changed the type of element_block_ptr to struct tui_win_element, which seems obvious (this is actually what raised the flag, casting the result of xmalloc to struct tui_win_element* wouldn't work). gdb/ChangeLog: * tui/tui-data.c (tui_alloc_content): Don't check xmalloc result. Change type of element_block_ptr. Change allocation to use XNEWVEC.
This commit is contained in:
parent
a6af384b19
commit
7acd011bef
@ -1,3 +1,9 @@
|
||||
2015-10-26 Simon Marchi <simon.marchi@ericsson.com>
|
||||
|
||||
* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
|
||||
result. Change type of element_block_ptr. Change allocation to
|
||||
use XNEWVEC.
|
||||
|
||||
2015-10-26 Luis Machado <lgustavo@codesourcery.com>
|
||||
|
||||
* record-full.c (record_full_message_wrapper_safe): Pass empty string to
|
||||
|
@ -573,12 +573,11 @@ tui_win_content
|
||||
tui_alloc_content (int num_elements, enum tui_win_type type)
|
||||
{
|
||||
tui_win_content content;
|
||||
char *element_block_ptr;
|
||||
struct tui_win_element *element_block_ptr;
|
||||
int i;
|
||||
|
||||
content = XNEWVEC (struct tui_win_element *, num_elements);
|
||||
if (content != NULL)
|
||||
{
|
||||
|
||||
/*
|
||||
* All windows, except the data window, can allocate the
|
||||
* elements in a chunk. The data window cannot because items
|
||||
@ -587,22 +586,12 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
|
||||
*/
|
||||
if (type != DATA_WIN)
|
||||
{
|
||||
element_block_ptr =
|
||||
xmalloc (sizeof (struct tui_win_element) * num_elements);
|
||||
if (element_block_ptr != NULL)
|
||||
{
|
||||
element_block_ptr = XNEWVEC (struct tui_win_element, num_elements);
|
||||
for (i = 0; i < num_elements; i++)
|
||||
{
|
||||
content[i] = (struct tui_win_element *) element_block_ptr;
|
||||
content[i] = element_block_ptr;
|
||||
init_content_element (content[i], type);
|
||||
element_block_ptr += sizeof (struct tui_win_element);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree (content);
|
||||
content = (tui_win_content) NULL;
|
||||
}
|
||||
element_block_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user