Example #1
0
node_t* search_key( node_t* node, key_type key ){
        if( node == NULL ){
                printf("Node not found\n");
                return NULL;
        }

        if( comp_key( key, node->key ) == 0 )
                return node;
        
        if( comp_key( key, node->key ) == -1 )
                search_key( node->left, key );
        else
                search_key( node->right, key);
}
Example #2
0
int
ACE_WIN32_Proactor::register_handle (ACE_HANDLE handle,
                                     const void *completion_key)
{
  ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));

  // No locking is needed here as no state changes.
  ACE_HANDLE cp = ::CreateIoCompletionPort (handle,
                                            this->completion_port_,
                                            comp_key,
                                            this->number_of_threads_);
  if (cp == 0)
    {
      ACE_OS::set_errno_to_last_error ();
      // If errno == ERROR_INVALID_PARAMETER, then this handle was
      // already registered.
      if (errno != ERROR_INVALID_PARAMETER)
        {
          if (ACE::debug ())
            {
              ACE_DEBUG ((LM_ERROR,
                          ACE_TEXT ("%p\n"),
                          ACE_TEXT ("CreateIoCompletionPort")));
            }
          return -1;
        }
    }
  return 0;
}
Example #3
0
void free_node(node_t* node){
        if( comp_key( node->key, node->parent->key ) == 1 )
                node->parent->right = NULL;
        else
                node->parent->left = NULL;

        free(node);
}
Example #4
0
void insert_key( node_t* node, key_type key ){
        node_t** child;

        if( comp_key( key, node->key ) == 0 ){
                printf("Node already exist!\n");
                return;
        }
        
        if( comp_key( key, node->key ) == -1 )
                child = &(node->left);
        else
                child = &(node->right);
        
        if( *child != NULL )
                insert_key( *child, key );
        else{
                *child = malloc(sizeof(node_t));
                copy_key( &( (*child)->key ), key);
                (*child)->left = NULL;
                (*child)->right = NULL;
                (*child)->parent = node;
                return;
        }
}