Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. typedef struct hash_fechada{
  2. TList **items;
  3. int TABLE_SIZE, qtd;
  4. }THashFechada;
  5.  
  6. THashFechada* cria_hash_fechada (int TABLE_SIZE, int size_element){
  7. THashFechada* ha = (THashFechada*) malloc(sizeof(THashFechada));
  8. if(ha != NULL){
  9. int i;
  10. ha->TABLE_SIZE = TABLE_SIZE;
  11. ha->items = (TList**) malloc(TABLE_SIZE * sizeof(TList*));
  12. if(ha->items == NULL){
  13. free(ha);
  14. return NULL;
  15. }
  16. ha->qtd = 0;
  17. for(i=0; i < ha->TABLE_SIZE; i++){
  18. ha->items[i] = malloc(sizeof(TList));
  19. ha->items[i]->element_size = size_element;
  20. ha->items[i]->size = 0;
  21. ha->items[i]->head = ha->items[i]->tail = NULL;
  22. ha->items[i]->free_fn = NULL;
  23. }
  24. }
  25. return ha;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement