--- projects/cms/source/ihost/ihost.c 2002/05/12 12:00:33 1.4 +++ projects/cms/source/ihost/ihost.c 2002/05/12 14:10:45 1.5 @@ -43,6 +43,13 @@ int ihost_configure(ihost_state_t *ihost_state){ char *reply; char *reply_ptr; + /* Check to see if anything needs to be free'd */ + if (ihost_state->fm_host!=NULL) free(ihost_state->fm_host); + if (ihost_state->my_fqdn!=NULL) free(ihost_state->my_fqdn); + if (ihost_state->server_fqdn!=NULL) free(ihost_state->server_fqdn); + if (ihost_state->last_modified!=NULL) free(ihost_state->last_modified); + if (ihost_state->files_list!=NULL) free(ihost_state->files_list); + if ((sd = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { errf("Can't create AF_INET socket (%m)"); return -1; @@ -253,7 +260,8 @@ int heartbeat(ihost_state_t *ihost_state){ errf("Server error"); return -1; } - + if (ihost_state->key!=NULL) free(ihost_state->key); + if((ihost_state->key=strdup(reply)) == NULL){ errf("strdup failed (%m)"); return -1; @@ -271,6 +279,15 @@ int heartbeat(ihost_state_t *ihost_state){ int main(int argc, char **argv){ ihost_state_t ihost_state; + + /* NULL'ify so i can tell if i need to free it or not */ + ihost_state.fm_host=NULL; + ihost_state.my_fqdn=NULL; + ihost_state.server_fqdn=NULL; + ihost_state.last_modified=NULL; + ihost_state.files_list=NULL; + ihost_state.key=NULL; + errf_set_progname(argv[0]); if(argc!=3){ errf_usage(" "); @@ -283,6 +300,7 @@ int main(int argc, char **argv){ if(ihost_configure(&ihost_state)!=0){ errf("configure failed"); } + return 0; }