/* * Function: ftpp_ui_client_lookup_cleanup(CLIENT_LOOKUP **ClientLookup) * * Purpose: Free the client_lookup structure. * We need to free the client_lookup structure. * * Arguments: ClientLookup => pointer to the pointer of the client * lookup structure. * * Returns: int => return code indicating error or success * */ int ftpp_ui_client_lookup_cleanup(CLIENT_LOOKUP **ClientLookup) { if ((ClientLookup == NULL) || (*ClientLookup == NULL)) return FTPP_INVALID_ARG; sfrt_cleanup(*ClientLookup, clientConfFree); sfrt_free(*ClientLookup); *ClientLookup = NULL; return FTPP_SUCCESS; }
/* * Function: ftpp_ui_server_lookup_cleanup(SERVER_LOOKUP **ServerLookup) * * Purpose: Free the server_lookup structure. * We need to free the server_lookup structure. * * Arguments: ServerLookup => pointer to the pointer of the server * lookup structure. * * Returns: int => return code indicating error or success * */ int ftpp_ui_server_lookup_cleanup(SERVER_LOOKUP **ServerLookup) { if ((ServerLookup == NULL) || (*ServerLookup == NULL)) return FTPP_INVALID_ARG; sfrt_cleanup(*ServerLookup, serverConfFree); sfrt_free(*ServerLookup); *ServerLookup = NULL; return FTPP_SUCCESS; }
int main() { table_t *dir; uint32_t ip_list[NUM_IPS]; /* entirely arbitrary */ char data[NUM_DATA]; /* also entirely arbitrary */ uint32_t index, val; for(index=0; index<NUM_IPS; index++) { ip_list[index] = (uint32_t)rand()%NUM_IPS; data[index%NUM_DATA] = index%26 + 65; /* Random letter */ } dir = sfrt_new(DIR_16x2, IPv4, NUM_IPS, 20); if(!dir) { printf("Failed to create DIR\n"); return 1; } for(index=0; index < NUM_IPS; index++) { if(sfrt_insert(&ip_list[index], 32, &data[index%NUM_DATA], RT_FAVOR_SPECIFIC, dir) != RT_SUCCESS) { printf("DIR Insertion failure\n"); return 1; } printf("%d\t %x: %c -> %c\n", index, ip_list[index], data[index%NUM_DATA], *(uint32_t*)sfrt_lookup(&ip_list[index], dir)); } for(index=0; index < NUM_IPS; index++) { val = *(uint32_t*)sfrt_lookup(&ip_list[index], dir); printf("\t@%d\t%x: %c. originally:\t%c\n", index, ip_list[index], val, data[index%NUM_DATA]); } printf("Usage: %d bytes\n", ((dir_table_t*)(dir->rt))->allocated); sfrt_free(dir); return 0; }
void hi_ui_server_lookup_destroy(SERVER_LOOKUP *ServerLookup) { sfrt_cleanup(ServerLookup, serverConfFree); sfrt_free(ServerLookup); }