void fatfs_node_cache_init(fatfs_disk_t *disk) { CYG_CHECK_DATA_PTRC(disk); node_list_init(&disk->live_nlist); node_list_init(&disk->dead_nlist); node_hash_init(&disk->node_hash); node_pool_init(disk); SANITY_CHECK(); }
void qnetd_client_init(struct qnetd_client *client, PRFileDesc *sock, PRNetAddr *addr, char *addr_str, size_t max_receive_size, size_t max_send_buffers, size_t max_send_size, struct timer_list *main_timer_list) { memset(client, 0, sizeof(*client)); client->socket = sock; client->addr_str = addr_str; memcpy(&client->addr, addr, sizeof(*addr)); dynar_init(&client->receive_buffer, max_receive_size); send_buffer_list_init(&client->send_buffer_list, max_send_buffers, max_send_size); node_list_init(&client->configuration_node_list); node_list_init(&client->last_membership_node_list); node_list_init(&client->last_quorum_node_list); client->main_timer_list = main_timer_list; }
int qdevice_instance_init(struct qdevice_instance *instance, const struct qdevice_advanced_settings *advanced_settings) { memset(instance, 0, sizeof(*instance)); node_list_init(&instance->config_node_list); instance->vq_last_poll = ((time_t) -1); instance->advanced_settings = advanced_settings; return (0); }
static inline void graph_nodes_realloc(graph_t *g, int32_t size) { int32_t i, prev_mem; if(size < g->nodes_mem) { return; } prev_mem = g->nodes_mem; g->nodes_mem = size; roundup32(g->nodes_mem); // round up assert(size <= g->nodes_mem); g->nodes = srma_realloc(g->nodes, sizeof(node_list_t*)*g->nodes_mem, __func__, "g->nodes"); for(i=prev_mem;i<g->nodes_mem;i++) { g->nodes[i] = node_list_init(); } }
graph_t *graph_init() { graph_t *g = NULL; g = srma_malloc(sizeof(graph_t), __func__, "g"); g->contig = 1; g->position_start = 1; g->position_end = 1; g->nodes = NULL; g->is_empty = 1; // Add a dummy node g->nodes = srma_malloc(sizeof(node_list_t*), __func__, "g->nodes"); g->nodes[0] = node_list_init(); g->nodes_mem = 1; return g; }
int qdevice_cmap_get_nodelist(cmap_handle_t cmap_handle, struct node_list *list) { cs_error_t cs_err; cmap_iter_handle_t iter_handle; char key_name[CMAP_KEYNAME_MAXLEN + 1]; char tmp_key[CMAP_KEYNAME_MAXLEN + 1]; int res; int ret_value; unsigned int node_pos; uint32_t node_id; uint32_t data_center_id; char *tmp_str; char *addr0_str; int clear_node_high_byte; ret_value = 0; node_list_init(list); cs_err = cmap_iter_init(cmap_handle, "nodelist.node.", &iter_handle); if (cs_err != CS_OK) { return (-1); } while ((cs_err = cmap_iter_next(cmap_handle, iter_handle, key_name, NULL, NULL)) == CS_OK) { res = sscanf(key_name, "nodelist.node.%u.%s", &node_pos, tmp_key); if (res != 2) { continue; } if (strcmp(tmp_key, "ring0_addr") != 0) { continue; } snprintf(tmp_key, CMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos); cs_err = cmap_get_uint32(cmap_handle, tmp_key, &node_id); if (cs_err == CS_ERR_NOT_EXIST) { /* * Nodeid doesn't exists -> autogenerate node id */ clear_node_high_byte = 0; if (cmap_get_string(cmap_handle, "totem.clear_node_high_bit", &tmp_str) == CS_OK) { if (strcmp (tmp_str, "yes") == 0) { clear_node_high_byte = 1; } free(tmp_str); } if (cmap_get_string(cmap_handle, key_name, &addr0_str) != CS_OK) { return (-1); } node_id = qdevice_cmap_autogenerate_node_id(addr0_str, clear_node_high_byte); free(addr0_str); } else if (cs_err != CS_OK) { ret_value = -1; goto iter_finalize; } snprintf(tmp_key, CMAP_KEYNAME_MAXLEN, "nodelist.node.%u.datacenterid", node_pos); if (cmap_get_uint32(cmap_handle, tmp_key, &data_center_id) != CS_OK) { data_center_id = 0; } if (node_list_add(list, node_id, data_center_id, TLV_NODE_STATE_NOT_SET) == NULL) { ret_value = -1; goto iter_finalize; } } iter_finalize: cmap_iter_finalize(cmap_handle, iter_handle); if (ret_value != 0) { node_list_free(list); } return (ret_value); }