/* Create Linked List */ struct esif_link_list *esif_link_list_create(void) { struct esif_link_list *new_link_list_ptr = NULL; new_link_list_ptr = (struct esif_link_list *) esif_ccb_mempool_zalloc(ESIF_MEMPOOL_TYPE_LIST); if (NULL == new_link_list_ptr) return NULL; new_link_list_ptr->head_ptr = NULL; new_link_list_ptr->tail_ptr = NULL; new_link_list_ptr->nodes = 0; return new_link_list_ptr; }
/* Create Node */ struct esif_link_list_node *esif_link_list_create_node(void *data_ptr) { struct esif_link_list_node *new_node_ptr = NULL; new_node_ptr = (struct esif_link_list_node *) esif_ccb_mempool_zalloc(ESIF_MEMPOOL_TYPE_LIST_NODE); if (NULL == new_node_ptr) return NULL; new_node_ptr->data_ptr = data_ptr; new_node_ptr->next_ptr = NULL; new_node_ptr->prev_ptr = NULL; return new_node_ptr; }
/* Create Hash Table */ struct esif_ht * esif_ht_create( u32 size ) { u32 index = 0; struct esif_ht *new_ht_ptr = NULL; new_ht_ptr = (struct esif_ht *) esif_ccb_mempool_zalloc(ESIF_MEMPOOL_TYPE_HASH2); if (NULL == new_ht_ptr) { ESIF_TRACE_ERROR("Cannot allocate mem for hash table\n"); ESIF_ASSERT(ESIF_FALSE); goto exit; } new_ht_ptr->size = size; new_ht_ptr->table = (struct esif_link_list **) esif_ccb_malloc(sizeof(*new_ht_ptr->table) * size); if (new_ht_ptr->table == NULL) { esif_ccb_mempool_free(ESIF_MEMPOOL_TYPE_HASH2, new_ht_ptr); new_ht_ptr = NULL; goto exit; } for (index = 0; index < size; ++index) { ESIF_TRACE_DYN_VERB("Create linked list %d\n", index); new_ht_ptr->table[index] = esif_link_list_create(); if (new_ht_ptr->table[index] == NULL) { ESIF_TRACE_DYN_VERB("Creation failed\n"); esif_ht_destroy(new_ht_ptr, NULL); new_ht_ptr = NULL; goto exit; } } ESIF_TRACE_DYN_VERB("Have hash table %p\n", new_ht_ptr); exit: return new_ht_ptr; }