Exemplo n.º 1
0
/**
 * Create map container auxiliary function.
 */
bool_t _create_map_auxiliary(map_t* pmap_map, const char* s_typename)
{
    char   s_typenameex[_TYPE_NAME_SIZE + 1];
    bool_t b_result = false;

    assert(pmap_map != NULL);
    assert(s_typename != NULL);

    b_result = _create_pair_auxiliary(&pmap_map->_pair_temp, s_typename);
    if(!b_result)
    {
        return false;
    }

    memset(s_typenameex, '\0', _TYPE_NAME_SIZE + 1);
    strncpy(s_typenameex, "pair_t", _TYPE_NAME_SIZE);
    strncat(s_typenameex, "<", _TYPE_NAME_SIZE);
    strncat(s_typenameex, s_typename, _TYPE_NAME_SIZE - 8); /* 8 is length of "pair_t<>" */
    strncat(s_typenameex, ">", _TYPE_NAME_SIZE);

#ifdef CSTL_MAP_AVL_TREE
    b_result = _create_avl_tree_auxiliary(&pmap_map->_t_tree, s_typenameex);
#else
    b_result = _create_rb_tree_auxiliary(&pmap_map->_t_tree, s_typenameex);
#endif

    pmap_map->_bfun_keycompare = NULL;
    pmap_map->_bfun_valuecompare = NULL;

    return b_result;
}
Exemplo n.º 2
0
/* pair_t */
void _type_init_pair(const void* cpv_input, void* pv_output)
{
    bool_t b_result = false;
    assert(cpv_input != NULL && pv_output != NULL);

    b_result = _create_pair_auxiliary((pair_t*)cpv_input, (char*)pv_output);
    assert(b_result);
    /* initialize pair */
    pair_init((pair_t*)cpv_input);
}
Exemplo n.º 3
0
/**
 * Create pair container.
 */
pair_t* _create_pair(const char* s_typename)
{
    pair_t*     ppair_pair = NULL;

    if ((ppair_pair = (pair_t*)malloc(sizeof(pair_t))) == NULL) {
        return NULL;
    }

    if (!_create_pair_auxiliary(ppair_pair, s_typename)) {
        free(ppair_pair);
        return NULL;
    }

    return ppair_pair;
}
/**
 * Create hash_multimap container auxiliary function.
 */
bool_t _create_hash_multimap_auxiliary(hash_multimap_t* phmmap_map, const char* s_typename)
{
    char s_typenameex[_TYPE_NAME_SIZE + 1];

    assert(phmmap_map != NULL);
    assert(s_typename != NULL);

    if(!_create_pair_auxiliary(&phmmap_map->_pair_temp, s_typename))
    {
        return false;
    }

    memset(s_typenameex, '\0', _TYPE_NAME_SIZE + 1);
    strncpy(s_typenameex, "pair_t", _TYPE_NAME_SIZE);
    strncat(s_typenameex, "<", _TYPE_NAME_SIZE);
    strncat(s_typenameex, s_typename, _TYPE_NAME_SIZE - 8); /* 8 is length of "pair_t<>" */
    strncat(s_typenameex, ">", _TYPE_NAME_SIZE);

    phmmap_map->_bfun_keycompare = NULL;
    phmmap_map->_bfun_valuecompare = NULL;

    return _create_hashtable_auxiliary(&phmmap_map->_t_hashtable, s_typenameex);
}