regions.c
/*
 *
 * CloseRegions -- close a regions and free up memory
 *
 */
- close a regions and free up memory
- close a regions and free up memory
int CloseRegions(Regions reg){
  int status=0;
  if( !reg || (reg == NOREGIONS) ){
    return 0;
  }
  switch(reg->method){
#if __EMSCRIPTEN__
  case METHOD_EM:
    break;
#else
  case METHOD_C:
    switch(reg->ptype){
    case PTYPE_PROCESS:
    case PTYPE_CONTAINED:
      switch(reg->pipeos){
      case PIPE_WIN32:
#if defined(__CYGWIN__) || defined(__MINGW32__)
	if( reg->process ){
	  WinProcessClose(reg->process, &status);
	}
#else
	xerror(stderr, "internal error: no WinProcess without Windows");
#endif
	break;
      default:
	if( reg->pid > 0 ){
	  ProcessClose(reg->pid, &status);
	}
	break;
      }
      if( reg->prog ){
	unlink(reg->prog);
      }
      break;
    case PTYPE_DYNAMIC:
      if( reg->dl ){
	status = DLClose(reg->dl);
      }
      break;
    default:
      break;
    }
    break;
#endif
  }
  RegionsProgClose(reg);
  RegionsProgEnd(reg);
  xfree(reg->pname);
  xfree(reg->mode);
  xfree(reg->cc);
  xfree(reg->cflags);
  xfree(reg->objs);
  xfree(reg->extra);
  xfree(reg->shflags);
  xfree(reg->code);
  xfree(reg->prog);
  xfree(reg->regstr);
  xfree(reg->cards);
  xfree(reg->radang);
  xfree(reg->filter);
  xfree(reg);
  return status;
}
int CloseRegions ( Regions reg ) { int status = 0 ; if ( ! reg || ( reg == NOREGIONS ) ) { return 0 ; } switch ( reg -> method ) { #if __EMSCRIPTEN__ case METHOD_EM : break ; #else case METHOD_C : switch ( reg -> ptype ) { case PTYPE_PROCESS : case PTYPE_CONTAINED : switch ( reg -> pipeos ) { case PIPE_WIN32 : #if defined ( __CYGWIN__ ) || defined ( __MINGW32__ ) if ( reg -> process ) { WinProcessClose ( reg -> process , & status ) ; } #else xerror ( stderr , " " ) ; #endif break ; default : if ( reg -> pid > 0 ) { ProcessClose ( reg -> pid , & status ) ; } break ; } if ( reg -> prog ) { unlink ( reg -> prog ) ; } break ; case PTYPE_DYNAMIC : if ( reg -> dl ) { status = DLClose ( reg -> dl ) ; } break ; default : break ; } break ; #endif } RegionsProgClose ( reg ) ; RegionsProgEnd ( reg ) ; xfree ( reg -> pname ) ; xfree ( reg -> mode ) ; xfree ( reg -> cc ) ; xfree ( reg -> cflags ) ; xfree ( reg -> objs ) ; xfree ( reg -> extra ) ; xfree ( reg -> shflags ) ; xfree ( reg -> code ) ; xfree ( reg -> prog ) ; xfree ( reg -> regstr ) ; xfree ( reg -> cards ) ; xfree ( reg -> radang ) ; xfree ( reg -> filter ) ; xfree ( reg ) ; return status ; }
CloseRegions -- close a regions and free up memory
CloseRegions -- close a regions and free up memory
/* close the regions process */ /* delete program */ /* call any method-specific cleanup routines */ /* free alloc'ed memory */ /* free main struct */ /* return the status from closing the sub-process */