unsigned int thash_insert( thash *t, void *value, unsigned int sz, char *key ) { unsigned int index = hash( key, t->size, SHIFT ); lista **selected, *elem; elem = lista_new(value, sz, key); selected = t->table + index; *selected = lista_insert( *selected, elem ); return index; }
int main(void) { struct lista *mi_lista; struct elem *e; struct elem *e2; int i=0; char **strp; /* creo una nueva lista */ mi_lista=lista_new(); /* creo un elemento por palabra y lo appendo a lista */ for(strp=palabras; *strp; strp++) { e=elem_new_string(*strp); if (i++==2) /* apunto al 3er (indice 2) elemento para luego borrarlo */ e2=e; lista_append_elem(mi_lista, e); } lista_print(mi_lista, stdout); lista_del_elem(mi_lista, e2); lista_print(mi_lista, stdout); return 0; }
TAPE *tape_new(char whiteChar){ TAPE *novo; if((novo = (TAPE*)malloc(sizeof(TAPE))) == NULL){ trgError_setDesc(TAPE_EALLOC_MSG); return (NULL); } if((novo->tape = lista_new()) == NULL){ trgError_setDesc(TAPE_EALLOC_MSG); free(novo); return (NULL); } novo->whiteChar = whiteChar; novo->actualSymbol = lista_getRaiz(novo->tape); return (novo); }