ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/ihost.c
(Generate patch)

Comparing projects/cms/source/ihost/ihost.c (file contents):
Revision 1.4 by pajs, Sun May 12 12:00:33 2002 UTC vs.
Revision 1.5 by pajs, Sun May 12 14:10:45 2002 UTC

# Line 43 | Line 43 | int ihost_configure(ihost_state_t *ihost_state){
43          char *reply;
44          char *reply_ptr;
45  
46 +        /* Check to see if anything needs to be free'd */
47 +        if (ihost_state->fm_host!=NULL) free(ihost_state->fm_host);
48 +        if (ihost_state->my_fqdn!=NULL) free(ihost_state->my_fqdn);
49 +        if (ihost_state->server_fqdn!=NULL) free(ihost_state->server_fqdn);
50 +        if (ihost_state->last_modified!=NULL) free(ihost_state->last_modified);
51 +        if (ihost_state->files_list!=NULL) free(ihost_state->files_list);
52 +
53          if ((sd = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) {
54                  errf("Can't create AF_INET socket (%m)");
55                  return -1;
# Line 253 | Line 260 | int heartbeat(ihost_state_t *ihost_state){
260                  errf("Server error");
261                  return -1;
262          }
263 <        
263 >        if (ihost_state->key!=NULL) free(ihost_state->key);
264 >
265          if((ihost_state->key=strdup(reply)) == NULL){
266                  errf("strdup failed (%m)");
267                  return -1;
# Line 271 | Line 279 | int heartbeat(ihost_state_t *ihost_state){
279  
280   int main(int argc, char **argv){
281          ihost_state_t ihost_state;
282 +
283 +        /* NULL'ify so i can tell if i need to free it or not */
284 +        ihost_state.fm_host=NULL;
285 +        ihost_state.my_fqdn=NULL;
286 +        ihost_state.server_fqdn=NULL;
287 +        ihost_state.last_modified=NULL;
288 +        ihost_state.files_list=NULL;
289 +        ihost_state.key=NULL;
290 +
291          errf_set_progname(argv[0]);
292          if(argc!=3){
293                  errf_usage("<host> <port>");    
# Line 283 | Line 300 | int main(int argc, char **argv){
300          if(ihost_configure(&ihost_state)!=0){
301                  errf("configure failed");
302          }
303 +
304  
305          return 0;
306   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines