struct remote *create_remote(char *name) { struct remote *rs; rs = malloc(sizeof(struct remote)); if(rs == NULL){ return NULL; } rs->r_name = NULL; rs->r_line = NULL; rs->r_index = 0; rs->r_state = RX_BAD; rs->r_count = 0; rs->r_vector = NULL; rs->r_match = NULL; rs->r_name = strdup(name); if(rs->r_name == NULL){ destroy_remote(rs); return NULL; } return rs; }
static void destroy_server (entity *en) { // // destroy remote entity first (keeping local entity valid) // validate_client_server_remote_fn (); destroy_remote (en); validate_client_server_local_fn (); // // destroy local using 'full' function // destroy_local_entity (en); }
static void destroy_client (entity *en) { if (get_comms_data_flow () == COMMS_DATA_FLOW_TX) { validate_client_server_remote_fn (); destroy_remote (en); } else { validate_client_server_local_fn (); // // destroy local using 'full' function // destroy_local_entity (en); } }
void destroy_set(struct set *ss) { unsigned int i; if(ss == NULL){ return; } for(i = 0; i < ss->s_count; i++){ destroy_remote(ss->s_vector[i]); ss->s_vector[i] = NULL; } if(ss->s_vector){ free(ss->s_vector); ss->s_vector = NULL; } ss->s_status = (-1); free(ss); }
struct remote *add_remote(struct set *ss, char *name) { struct remote *rs; struct remote **tmp; rs = create_remote(name); if(rs == NULL){ return NULL; } tmp = realloc(ss->s_vector, sizeof(struct remote *) * (ss->s_count + 1)); if(tmp == NULL){ destroy_remote(rs); return NULL; } ss->s_vector = tmp; ss->s_vector[ss->s_count] = rs; ss->s_count++; return rs; }