(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/stats_tree.c) |
| |
| 427 | | | static stat_node* |
| 428 | | | new_stat_node(stats_tree *st, const gchar *name, int parent_id, |
| 429 | | | gboolean with_hash, gboolean as_parent_node) |
| 430 | | | { |
| 431 | | | |
| 432 | | | stat_node *node = g_malloc (sizeof(stat_node)); |
| 433 | | | stat_node *last_chld = NULL; |
| 434 | | | |
| 435 | | | node->counter = 0; |
| 436 | | | node->name = g_strdup(name); |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 437 | | | node->children = NULL; |
| 438 | | | node->next = NULL; |
| 439 | | | node->st = (stats_tree*) st; |
| 440 | | | node->hash = with_hash ? g_hash_table_new(g_str_hash,g_str_equal) : NULL; |
| 441 | | | node->parent = NULL; |
| 442 | | | node->rng = NULL; |
| 443 | | | |
| 444 | | | if (as_parent_node) { |
| 445 | | | g_hash_table_insert(st->names, |
| 446 | | | node->name, |
| 447 | | | node); |
| 448 | | | |
| 449 | | | g_ptr_array_add(st->parents,node); |
| 450 | | | |
| 451 | | | node->id = st->parents->len - 1; |
| 452 | | | } else { |
| 453 | | | node->id = -1; |
| 454 | | | } |
| 455 | | | |
| 456 | | | if (parent_id >= 0 && parent_id < (int) st->parents->len ) { |
| 457 | | | node->parent = g_ptr_array_index(st->parents,parent_id);
x /usr/include/glib-2.0/glib/garray.h |
| |
111 | #define g_ptr_array_index(array,index_) ((array)->pdata)[index_] |
| |
|
| 458 | | | } else { |
| 459 | | | |
| 460 | | | g_assert_not_reached();
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
73 | #define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 461 | | | } |
| 462 | | | |
| 463 | | | if (node->parent->children) { |
| 464 | | | |
| 465 | | | |
| 466 | | | for (last_chld = node->parent->children; |
| 467 | | | last_chld->next; |
| 468 | | | last_chld = last_chld->next ) ; |
| 469 | | | |
| 470 | | | last_chld->next = node; |
| 471 | | | |
| 472 | | | } else { |
| 473 | | | |
| 474 | | | node->parent->children = node; |
| 475 | | | } |
| 476 | | | |
| 477 | | | if(node->parent->hash) { |
| 478 | | | g_hash_table_insert(node->parent->hash,node->name,node); |
| 479 | | | } |
| 480 | | | |
| 481 | | | if (st->cfg->setup_node_pr) { |
| 482 | | | st->cfg->setup_node_pr(node); |
| 483 | | | } else { |
| 484 | | | node->pr = NULL; |
| 485 | | | } |
| 486 | | | |
| 487 | | | return node; |
| 488 | | | } |
| |