示例#1
0
void switch_lpm_trie_insert(switch_lpm_trie_t *trie,
                            const char *prefix,
                            int prefix_length,
                            const value_t value) {
  node_t *current_node = trie->root;
  byte_t byte;
  unsigned short prefix_key;

  while (prefix_length >= 8) {
    byte = (byte_t)*prefix;
    node_t *node = get_next_node(current_node, byte);
    if (!node) {
      allocate_node(&node);
      node->parent = current_node;
      node->child_id = byte;
      set_next_node(current_node, byte, node);
      current_node->branch_num++;
    }

    prefix++;
    prefix_length -= 8;
    current_node = node;
  }

  if (prefix_length == 0)
    prefix_key = 0;
  else
    prefix_key = get_prefix_key((unsigned)prefix_length, (byte_t)*prefix);

  if (!insert_prefix(current_node, prefix_key, value)) current_node->pref_num++;

  trie->num_entries++;
}
VariableDeclarationNode::VariableDeclarationNode(
    const int identifier,
    const Token::TokenName &type,
    VariableDeclarationNode *next_variable_declaration) 
  : DeclarationNode(identifier, type) {
  array_expression_ = NULL;
  array_variable_ = false;
  set_next_node(next_variable_declaration);
}
VariableDeclarationNode::VariableDeclarationNode(
    VariableDeclarationNode *next_variable_declaration) {
  set_next_node(next_variable_declaration);
}