src/console/console_conf.c
void free_resource(RES *rres, int type)
{
   URES *res = (URES *)rres;

   if (res == NULL) {
      return;
   }

   /* common stuff -- free the resource name */
   if (res->res_dir.hdr.name) {
      free(res->res_dir.hdr.name);
   }
   if (res->res_dir.hdr.desc) {
      free(res->res_dir.hdr.desc);
   }

   switch (type) {
   case R_CONSOLE:
      if (res->res_cons.rc_file) {
         free(res->res_cons.rc_file);
      }
      if (res->res_cons.hist_file) {
         free(res->res_cons.hist_file);
      }
      if (res->res_cons.tls_ctx) {
         free_tls_context(res->res_cons.tls_ctx);
      }
      if (res->res_cons.tls_ca_certfile) {
         free(res->res_cons.tls_ca_certfile);
      }
      if (res->res_cons.tls_ca_certdir) {
         free(res->res_cons.tls_ca_certdir);
      }
      if (res->res_cons.tls_certfile) {
         free(res->res_cons.tls_certfile);
      }
      if (res->res_cons.tls_keyfile) {
         free(res->res_cons.tls_keyfile);
      }
      if (res->res_cons.director) {
         free(res->res_cons.director);
      }
      if (res->res_cons.password) {
         free(res->res_cons.password);
      }
      break;
   case R_DIRECTOR:
      if (res->res_dir.address) {
         free(res->res_dir.address);
      }
      if (res->res_dir.tls_ctx) {
         free_tls_context(res->res_dir.tls_ctx);
      }
      if (res->res_dir.tls_ca_certfile) {
         free(res->res_dir.tls_ca_certfile);
      }
      if (res->res_dir.tls_ca_certdir) {
         free(res->res_dir.tls_ca_certdir);
      }
      if (res->res_dir.tls_certfile) {
         free(res->res_dir.tls_certfile);
      }
      if (res->res_dir.tls_keyfile) {
         free(res->res_dir.tls_keyfile);
      }
      if (res->res_dir.password) {
         free(res->res_dir.password);
      }
      break;
   default:
      printf(_("Unknown resource type %d\n"), type);
   }
   /* Common stuff again -- free the resource, recurse to next one */
   free(res);
}
/*
 * Free memory of resource.
 * NB, we don't need to worry about freeing any references
 * to other resources as they will be freed when that
 * resource chain is traversed.  Mainly we worry about freeing
 * allocated strings (names).
 */
Free memory of resource.
NB, we don't need to worry about freeing any references
to other resources as they will be freed when that
resource chain is traversed.  Mainly we worry about freeing
allocated strings (names).
Free memory of resource . NB we don ' t need to worry about freeing any references to other resources as they will be freed when that resource chain is traversed . Mainly we worry about freeing allocated strings ( names ) .
void free_resource(RES *rres, int type)
{
   URES *res = (URES *)rres;
   if (res == NULL) {
      return;
   }
   if (res->res_dir.hdr.name) {
      free(res->res_dir.hdr.name);
   }
   if (res->res_dir.hdr.desc) {
      free(res->res_dir.hdr.desc);
   }
   switch (type) {
   case R_CONSOLE:
      if (res->res_cons.rc_file) {
         free(res->res_cons.rc_file);
      }
      if (res->res_cons.hist_file) {
         free(res->res_cons.hist_file);
      }
      if (res->res_cons.tls_ctx) {
         free_tls_context(res->res_cons.tls_ctx);
      }
      if (res->res_cons.tls_ca_certfile) {
         free(res->res_cons.tls_ca_certfile);
      }
      if (res->res_cons.tls_ca_certdir) {
         free(res->res_cons.tls_ca_certdir);
      }
      if (res->res_cons.tls_certfile) {
         free(res->res_cons.tls_certfile);
      }
      if (res->res_cons.tls_keyfile) {
         free(res->res_cons.tls_keyfile);
      }
      if (res->res_cons.director) {
         free(res->res_cons.director);
      }
      if (res->res_cons.password) {
         free(res->res_cons.password);
      }
      break;
   case R_DIRECTOR:
      if (res->res_dir.address) {
         free(res->res_dir.address);
      }
      if (res->res_dir.tls_ctx) {
         free_tls_context(res->res_dir.tls_ctx);
      }
      if (res->res_dir.tls_ca_certfile) {
         free(res->res_dir.tls_ca_certfile);
      }
      if (res->res_dir.tls_ca_certdir) {
         free(res->res_dir.tls_ca_certdir);
      }
      if (res->res_dir.tls_certfile) {
         free(res->res_dir.tls_certfile);
      }
      if (res->res_dir.tls_keyfile) {
         free(res->res_dir.tls_keyfile);
      }
      if (res->res_dir.password) {
         free(res->res_dir.password);
      }
      break;
   default:
      printf(_("Unknown resource type %d\n"), type);
   }
   free(res);
}
void free_resource ( RES * rres , int type ) { URES * res = ( URES * ) rres ; if ( res == NULL ) { return ; } if ( res -> res_dir . hdr . name ) { free ( res -> res_dir . hdr . name ) ; } if ( res -> res_dir . hdr . desc ) { free ( res -> res_dir . hdr . desc ) ; } switch ( type ) { case R_CONSOLE : if ( res -> res_cons . rc_file ) { free ( res -> res_cons . rc_file ) ; } if ( res -> res_cons . hist_file ) { free ( res -> res_cons . hist_file ) ; } if ( res -> res_cons . tls_ctx ) { free_tls_context ( res -> res_cons . tls_ctx ) ; } if ( res -> res_cons . tls_ca_certfile ) { free ( res -> res_cons . tls_ca_certfile ) ; } if ( res -> res_cons . tls_ca_certdir ) { free ( res -> res_cons . tls_ca_certdir ) ; } if ( res -> res_cons . tls_certfile ) { free ( res -> res_cons . tls_certfile ) ; } if ( res -> res_cons . tls_keyfile ) { free ( res -> res_cons . tls_keyfile ) ; } if ( res -> res_cons . director ) { free ( res -> res_cons . director ) ; } if ( res -> res_cons . password ) { free ( res -> res_cons . password ) ; } break ; case R_DIRECTOR : if ( res -> res_dir . address ) { free ( res -> res_dir . address ) ; } if ( res -> res_dir . tls_ctx ) { free_tls_context ( res -> res_dir . tls_ctx ) ; } if ( res -> res_dir . tls_ca_certfile ) { free ( res -> res_dir . tls_ca_certfile ) ; } if ( res -> res_dir . tls_ca_certdir ) { free ( res -> res_dir . tls_ca_certdir ) ; } if ( res -> res_dir . tls_certfile ) { free ( res -> res_dir . tls_certfile ) ; } if ( res -> res_dir . tls_keyfile ) { free ( res -> res_dir . tls_keyfile ) ; } if ( res -> res_dir . password ) { free ( res -> res_dir . password ) ; } break ; default : printf ( _ ( " \n " ) , type ) ; } free ( res ) ; }
Free memory of resource.
Free memory of resource .
/* common stuff -- free the resource name */ /* Common stuff again -- free the resource, recurse to next one */