示例#1
0
struct trie_node * new_trie_node() {
    struct trie_node * new_trie_node = ( struct trie_node * ) malloc( sizeof( struct trie_node ) );
    if ( ! new_trie_node ) {
	return NULL;
    }
    new_trie_node->accepting_type = NULL;
    new_trie_node->child = new_charhash();
    if ( ! new_trie_node->child ) {
	return NULL;
    }
    return new_trie_node;
}
struct hash * new_hash() {

    struct hash * newnode = ( struct hash * ) malloc(sizeof(struct hash));

    if( ! newnode ) return NULL;

    newnode->data = 0;
    newnode->sigstr = malloc( 1 *sizeof(char) );
    if( ! newnode->sigstr ) {
        return 0;
    }
    *newnode->sigstr = '\0';
    newnode->child = new_charhash();
    if( ! newnode->child ) {
        return 0;
    }
    newnode->num_children = 0;
    return newnode;

} // End function new_hash.