Ejemplo n.º 1
0
extern sd_hash_iter_t* sd_hash_lookadd(sd_hash_t* a_this, const void* a_key)
{
    int			h;
    sd_hash_iter_t*	p;

    if (a_this == 0 || a_key == 0)			return 0;
    if ((p = sd_hash_lookup(a_this, a_key)) != 0)	return p;
    if ((p = sd_calloc(1, sizeof(*p))) == 0)		return 0;

    if (a_this->ops->key_dup != 0)
        p->key = a_this->ops->key_dup(a_key);
    else
        p->key = (void*) a_key;

    p->hash					= a_this;
    p->__hkey					= a_this->ops->hash(a_key);

    if (a_this->nelem > SD_HASH_FULLTAB * a_this->size) rehash(a_this);

    h						= hindex(p->__hkey,
                                     a_this->size);
    p->__next					= a_this->tab[h];
    a_this->tab[h]				= p;
    if (p->__next != 0) p->__next->__prev	= p;

    a_this->nelem++;

    return p;
}
Ejemplo n.º 2
0
extern const log4c_layout_type_t* log4c_layout_type_get(const char* a_name)
{
    sd_hash_iter_t* i;
    
    if (!a_name)
	return NULL;

    if ( (i = sd_hash_lookup(log4c_layout_types(), a_name)) != NULL)
	return i->data;

    return NULL;
}