engine/source/scriptlib/List.c
/* returns the first node of which name is equal to theName */
returns the first node of which name is equal to theName
returns the first node of which name is equal to theName
Node *List_GetNodeByName(List *list, const char *name)
{
#ifdef DEBUG
    chklist((List *)list);
#endif
    Node *nptr;
    if (!name)
    {
        return NULL;
    }
#ifdef USE_STRING_HASHES
    size_t i;
    unsigned char h = strhash(name);
    if (!list->buckets || !list->buckets[h])
    {
        return 0;
    }
    for(i = 0; i < list->buckets[h]->used; i++)
    {
        nptr = list->buckets[h]->nodes[i];
        if(nptr && strcmp(name, nptr->name) == 0)
        {
            return list->buckets[h]->nodes[i];
        }
    }
    return NULL;
#else
    nptr = list->first;
    while (nptr)
    {
        if (nptr->name)
        {
            if (strcmp( nptr->name, name ) == 0)
            {
                return nptr;
            }
        }
        nptr = nptr->next;
    }
    return NULL;
#endif
}
Node * List_GetNodeByName ( List * list , const char * name ) { #ifdef DEBUG chklist ( ( List * ) list ) ; #endif Node * nptr ; if ( ! name ) { return NULL ; } #ifdef USE_STRING_HASHES size_t i ; unsigned char h = strhash ( name ) ; if ( ! list -> buckets || ! list -> buckets [ h ] ) { return 0 ; } for ( i = 0 ; i < list -> buckets [ h ] -> used ; i ++ ) { nptr = list -> buckets [ h ] -> nodes [ i ] ; if ( nptr && strcmp ( name , nptr -> name ) == 0 ) { return list -> buckets [ h ] -> nodes [ i ] ; } } return NULL ; #else nptr = list -> first ; while ( nptr ) { if ( nptr -> name ) { if ( strcmp ( nptr -> name , name ) == 0 ) { return nptr ; } } nptr = nptr -> next ; } return NULL ; #endif }
returns the first node of which name is equal to theName
returns the first node of which name is equal to theName