コード例 #1
0
ファイル: list.c プロジェクト: loverg-c/rattrapage_c
void		my_putinlist(t_list_rec **list, char **str, int *i)
{
  t_list_rec	*elem;
  int		j;
  char		*afterpc;
  char		**res;

  if ((res = malloc(1 * sizeof(char*))) == NULL)
    error_message("malloc");
  res[0] = NULL;
  elem = malloc_list(sizeof (t_list_rec));
  j = go_to_pc(str[*i]);
  elem->recettes = copy_recette(str, i, &j);
  elem->type = copy_afterpc(&j, str[*i]);
  *i += 1;
  if (str[*i] && str[*i][0] != '\0')
    {
      j = go_to_pc(str[*i]);
      afterpc = copy_afterpc(&j, str[*i]);
      while (my_strcmp(afterpc, "entree") != 0 && str[*i] &&
	     my_strcmp(afterpc, "plat") != 0 &&
	     my_strcmp(afterpc, "dessert") != 0 && str[*i][0] != '\0')
	res = my_copy_line(res, copy_ingredient(str, i, &j, &afterpc));
    }
  elem->ingredient = res;
  elem->next = *list;
  *list = elem;
}
コード例 #2
0
ファイル: main.c プロジェクト: hemiao3000/code
int main()
{
	int i = 0;

	struct list* hashmap[4];

	for (i = 0; i < 4; i++)
		hashmap[i] = malloc_list();


	for (; i < 200; i++)
		add_item(hashmap, i);
	
	struct node* node = find_item(hashmap, 71);

	printf("%p: %d\n", node, node->data);
	printf("%d %d\n", node->prev->data, node->next->data);

	return 0;
}
コード例 #3
0
int main(int argc, char **argv) 
{
    const char      *hmmfile;	/* file to read HMMs from                  */
    FILE            *fp;	/* output file handle                      */
    HMMFILE         *hmmfp;	/* opened hmmfile for reading              */
    struct plan7_s  *hmm;	/* HMM to generate from                    */
    int              L;		/* length of a sequence                    */
    int              i;		/* counter over sequences                  */

    char            *ofile;	/* output sequence file                    */
    int              nseq;	/* number of seqs to sample                */
    int              seed;	/* random number generator seed            */
    int              be_quiet;	/* TRUE to silence header/footer           */
    int              do_alignment; /* TRUE to output in aligned format     */ 
    int              do_consensus; /* TRUE to do a single consensus seq    */

    AjBool ajselex;
    AjBool ajcons;
    AjPFile inf=NULL;
    AjPFile outf=NULL;
    AjPStr  instr=NULL;
    AjPStr  outstr=NULL;
  

#ifdef MEMDEBUG
    unsigned long histid1, histid2, orig_size, current_size;
    orig_size = malloc_inuse(&histid1);
    fprintf(stderr, "[... memory debugging is ON ...]\n");
#endif

    /*********************************************** 
     * Parse command line
     ***********************************************/

    nseq         = 10;

    be_quiet     = FALSE;
    do_alignment = FALSE;  
    do_consensus = FALSE;
    ofile        = NULL;

    embInitPV("ohmmemit",argc,argv,"HMMER",VERSION);

    ajselex = ajAcdGetBoolean("selex");
    ajcons  = ajAcdGetBoolean("consensus");
    nseq    = ajAcdGetInt("number");
    seed    = ajAcdGetInt("seed");
    inf     = ajAcdGetInfile("infile");
    outf    = ajAcdGetOutfile("outfile");
  
    if(!seed)
	seed = time ((time_t *) NULL);

    if(ajselex)
	do_alignment=TRUE;
    else
	do_alignment=FALSE;
  
    if(ajcons)
	do_consensus=TRUE;
    else
	do_consensus=FALSE;

    instr  = ajStrNewC((char *)ajFileGetNameC(inf));
    outstr = ajStrNewC((char *)ajFileGetNameC(outf));

    hmmfile = ajStrGetPtr(instr);

    sre_srandom(seed);

    if (do_alignment && do_consensus)
	ajFatal("Sorry, -selex and -consensus are incompatible.\n"); 
    if (nseq != 10 && do_consensus)
	ajWarn("-consensus overrides -number (# of sampled seqs)");

    /*********************************************** 
     * Open HMM file (might be in HMMERDB or current directory).
     * Read a single HMM from it.
     ***********************************************/

    if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL)
	ajFatal("Failed to open HMM file %s\n", hmmfile);
    if (!HMMFileRead(hmmfp, &hmm)) 
	ajFatal("Failed to read any HMMs from %s\n", hmmfile);
    HMMFileClose(hmmfp);
    if (hmm == NULL) 
	ajFatal("HMM file %s corrupt or in incorrect format? Parse failed",
		hmmfile);

    /* Configure the HMM to shut off N,J,C emission: so we
     * do a simple single pass through the model.
     */
    Plan7NakedConfig(hmm);
    Plan7Renormalize(hmm);

    /*********************************************** 
     * Open the output file, or stdout
     ***********************************************/ 

    fp = ajFileGetFileptr(outf);
  
 
    /*********************************************** 
     * Show the options banner
     ***********************************************/
    be_quiet=TRUE;
    if (! be_quiet) 
    {
	printf("HMM file:             %s\n", hmmfile);
	if (! do_consensus)
	{
	    printf("Number of seqs:       %d\n", nseq);
	    printf("Random seed:          %d\n", seed);
	}
	printf("- - - - - - - - - - - - - - - - - - - - - - - - - "
	       "- - - - - - -\n\n");
    }

    /*********************************************** 
     * Do the work.
     * If we're generating an alignment, we have to collect
     * all our traces, then output. If we're generating unaligned
     * sequences, we can emit one at a time.
     ***********************************************/

    if (do_consensus) 
    {
	char    *seq;
	SQINFO   sqinfo;	/* info about sequence (name/desc)        */

	EmitConsensusSequence(hmm, &seq, NULL, &L, NULL);
	strcpy(sqinfo.name, "consensus");
	sqinfo.len = L;
	sqinfo.flags = SQINFO_NAME | SQINFO_LEN;

	WriteSeq(fp, kPearson, seq, &sqinfo);
	free(seq);
    }
    else if (do_alignment)
    {
	struct p7trace_s **tr;
	char           **dsq;
	SQINFO          *sqinfo;
	char           **aseq;
	AINFO            ainfo;
	float           *wgt;

	dsq    = MallocOrDie(sizeof(char *)             * nseq);
	tr     = MallocOrDie(sizeof(struct p7trace_s *) * nseq);
	sqinfo = MallocOrDie(sizeof(SQINFO)             * nseq);
	wgt    = MallocOrDie(sizeof(float)              * nseq);
	FSet(wgt, nseq, 1.0);

	for (i = 0; i < nseq; i++)
	{
	    EmitSequence(hmm, &(dsq[i]), &L, &(tr[i]));
	    sprintf(sqinfo[i].name, "seq%d", i+1);
	    sqinfo[i].len   = L;
	    sqinfo[i].flags = SQINFO_NAME | SQINFO_LEN;
	}

	P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, FALSE, 
			   &aseq, &ainfo);

	/* Output the alignment */
	WriteSELEX(fp, aseq, &ainfo, 50);
	if (ofile != NULL && !be_quiet)
	    printf("Alignment saved in file %s\n", ofile);

	/* Free memory
	 */
	for (i = 0; i < nseq; i++) 
	{
	    P7FreeTrace(tr[i]);
	    free(dsq[i]);
	}
	FreeAlignment(aseq, &ainfo);
	free(sqinfo);
	free(dsq);
	free(wgt);
	free(tr);
    }
    else				/* unaligned sequence output */
    {
	struct p7trace_s *tr;
	char             *dsq;
	char             *seq;
	SQINFO            sqinfo;

	for (i = 0; i < nseq; i++)
	{
	    EmitSequence(hmm, &dsq, &L, &tr);
	    sprintf(sqinfo.name, "seq%d", i+1);
	    sqinfo.len   = L;
	    sqinfo.flags = SQINFO_NAME | SQINFO_LEN;

	    seq = DedigitizeSequence(dsq, L);

	    WriteSeq(fp, kPearson, seq, &sqinfo);
	  
	    P7FreeTrace(tr);
	    free(dsq);
	    free(seq);
	}
    }

    ajFileClose(&outf);
  
    FreePlan7(hmm);
    SqdClean();

#ifdef MEMDEBUG
    current_size = malloc_inuse(&histid2);
    if (current_size != orig_size)
	malloc_list(2, histid1, histid2);
    else
	fprintf(stderr, "[No memory leaks.]\n");
#endif


    ajStrDel(&instr);
    ajStrDel(&outstr);
    ajFileClose(&inf);
    ajFileClose(&outf);

    embExit();
    return 0;
}
コード例 #4
0
/*!
 * @brief Reset WiFi_engine. 
 *
 * This will reset the state machine to the PowerOff state.  This
 * function should be called if the hardware is removed but the
 * driver/WiFiEngine remains loaded.
 */
int WiFiEngine_Unplug() 
{
   if (! WES_TEST_FLAG(WES_FLAG_HW_PRESENT))
   {
      DE_TRACE_STATIC(TR_INITIALIZE, "No HW present!\n");
      return WIFI_ENGINE_SUCCESS;
   }
   WIFI_LOCK();
   WES_CLEAR_FLAG(WES_FLAG_HW_PRESENT);
   WIFI_UNLOCK();

#if (DE_BUILTIN_SUPPLICANT == CFG_INCLUDED)
   /* there is an asymmetry here, we init wpa supplicant in
      configure_device, but there is not un-configure_device */
   if(WES_TEST_FLAG(WES_DEVICE_CONFIGURED))
   {
      wpa_exit();
   }
#endif

   /* Reset state machine */
   HMG_Unplug_ps();
   HMG_Unplug_traffic();

#if (DE_ENABLE_CM_SCAN == CFG_ON)
   /* XXX this should be handled with generic unplug mechanism */
   wei_cm_scan_unplug();
#endif
   wei_cm_unplug(wifiEngineState.cm_priv);
   wei_interface_unplug();
   wei_data_unplug();
   wei_ps_unplug();   

   /* Drain signals */
   wei_sm_drain_sig_q();

   wei_clear_cmd_queue();
   wei_clear_mib_reply_list();
   wei_clear_console_reply_list();

   wei_asscache_free();

   wei_arp_filter_unplug();
   wei_ind_unplug();

   /*  Free timers */
   DriverEnvironment_FreeTimer(wifiEngineState.mic_cm_detect_timer_id);
   DriverEnvironment_FreeTimer(wifiEngineState.mic_cm_assoc_holdoff_timer_id);
   DriverEnvironment_FreeTimer(wifiEngineState.monitor_traffic_timer_id);

#ifdef USE_IF_REINIT   
   DriverEnvironment_FreeTimer(wifiEngineState.inactivity_timer_id);
#endif
   DriverEnvironment_FreeTimer(wifiEngineState.cmd_timer_id);   
   DriverEnvironment_FreeTimer(wifiEngineState.ps_traffic_timeout_timer_id);  

#if (DE_CCX == CFG_INCLUDED)
   wei_ccx_unplug();
#endif
   /*  Free dynamic members in wifiEngineState */
   WrapperFreeStructure(wifiEngineState.active_channels_ref);
   wifiEngineState.active_channels_ref = NULL;

   WES_CLEAR_FLAG(WES_DEVICE_CONFIGURED);

   /* some stuff from WiFiEngine_Reinitialize */
   wei_netlist_free_all_nets();
   WiFiEngine_RateMonInit(); 
   wei_pmkid_unplug();
   wei_shutdown_roam();
   wei_shutdown_scan();
   wei_shutdown_auth();
   wei_unplug_mib();   
   wei_initialize_mib();
   wei_initialize_auth();
   wei_initialize_scan(); 
   wei_virt_trig_unplug();

   /* This must happen last since some components may be using cbc structures. */
   wei_cb_unplug();

#if (DE_DEBUG_MODE & CFG_MEMORY)
   {
      /* Always trace how much dynamic memory the driver have allocated.                 */
      /* If it increases after a activate-deactivate, list the buffers to find the leak. */
      static int last_sum_allocated = 0;
      int        sum_allocated =  malloc_sum();     
      DE_TRACE_INT(TR_INITIALIZE, "Memory allocated by malloc at unplug: %d\n", sum_allocated );
      if (sum_allocated > last_sum_allocated)
      {
         malloc_list();
      }
      last_sum_allocated = sum_allocated;
   }
#endif

   DE_TRACE_STATIC(TR_INITIALIZE, "Done!\n");

   return WIFI_ENGINE_SUCCESS;
}
コード例 #5
0
/*!
 * @brief Start WiFiEngine.
 *
 * If the current platform supports having the driver/WiFiEngine
 * loaded while the device hardware is not present then WiFiEngine
 * can be loaded (initialized) but unplugged (not sending to the
 * device). WiFiEngine_Plug() activates WiFiEngine and should be
 * called when the hardware device is present and ready to start
 * processing requests.
 */
int WiFiEngine_Plug()
{
   int i;
   rHostDriverProperties *hp;

#if (DE_DEBUG_MODE & CFG_MEMORY)
   {
      /* Always trace how much dynamic memory the driver have allocated.                 */
      /* If it increases after a deactivate-activate, list the buffers to find the leak. */
      static int last_sum_allocated = 0;
      int        sum_allocated =  malloc_sum();     
      DE_TRACE_INT(TR_INITIALIZE, "Memory allocated by malloc at plug: %d\n", sum_allocated );
      if (sum_allocated > last_sum_allocated)
      {
         malloc_list();
      }
      last_sum_allocated = sum_allocated;
   }
#endif

   WIFI_LOCK();
   wifiEngineState.dataReqPending = 0;
   DE_MEMSET(&wifiEngineState.dataReqByPrio, 0, 
             sizeof(wifiEngineState.dataReqByPrio));
   wifiEngineState.txPktWindowMax = WIFI_ENGINE_MAX_PENDING_REPLIES;
   wifiEngineState.cmdReplyPending = 0;
   wifiEngineState.dataPathState = DATA_PATH_OPENED;
   wifiEngineState.users = 0;
   wifiEngineState.users = RESOURCE_DISABLE_PS;   
   wifiEngineState.flags = 0;
   wifiEngineState.ps_inhibit_state = 0; 
   WES_SET_FLAG(WES_FLAG_HW_PRESENT);
   WES_SET_FLAG(WES_FLAG_8021X_PORT_OPEN);
   wifiEngineState.pkt_cnt = 1;
   wifiEngineState.current_seq_num = 0;
   wifiEngineState.last_seq_num = 0;
   wifiEngineState.frag_thres = 0;
   wifiEngineState.periodic_scan_interval = 0;
   wifiEngineState.ps_data_ind_received = 0;
   DE_MEMSET(&wifiEngineState.key_state, 0, sizeof wifiEngineState.key_state);
   wifiEngineState.core_dump_state = WEI_CORE_DUMP_DISABLED;
#ifdef USE_IF_REINIT   
   WEI_ACTIVITY();
#endif
   WEI_CMD_TX();
   wifiEngineState.forceRestart = 0;
#ifdef USE_NEW_AGE
   wifiEngineState.scan_count = 0;
#endif
   WIFI_UNLOCK();
   
   /* These two queues are declared in wifi_engine_internal.h */
   init_queue(&cmd_queue);
   wei_console_init();
   wei_data_plug();
   wei_ps_plug();
   wei_interface_plug();

   wei_cm_plug(wifiEngineState.cm_priv);

#ifdef ENABLE_STATE_TRACE
   transid_hist_init();
#endif /* ENABLE_STATE_TRACE */
   
   wei_asscache_init();

   i = DriverEnvironment_GetNewTimer(&wifiEngineState.mic_cm_detect_timer_id, FALSE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);
   i = DriverEnvironment_GetNewTimer(&wifiEngineState.mic_cm_assoc_holdoff_timer_id , FALSE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);
   i = DriverEnvironment_GetNewTimer(&wifiEngineState.monitor_traffic_timer_id, TRUE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);

#ifdef USE_IF_REINIT
   i = DriverEnvironment_GetNewTimer(&wifiEngineState.inactivity_timer_id, TRUE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);
#endif
   i = DriverEnvironment_GetNewTimer(&wifiEngineState.cmd_timer_id, TRUE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);
   i = DriverEnvironment_GetNewTimer(&wifiEngineState.ps_traffic_timeout_timer_id, TRUE);
   DE_ASSERT(i == DRIVERENVIRONMENT_SUCCESS);

#if (DE_CCX == CFG_INCLUDED)
   wei_ccx_plug();
#endif
   wifiEngineState.main_state = driverDisconnected;

#if 0
   /* Initialize the state machine */
   if(registry.hostDriver.hmgAutoMode)
   {
      HMG_Set_Traffic_Mode(TRAFFIC_AUTO_CONNECT);
   }
   else
   {
      HMG_Set_Traffic_Mode(TRAFFIC_TRANSPARENT);
   }
#endif
   wei_sm_init();

   hp = (rHostDriverProperties *)Registry_GetProperty(ID_hostDriver);  
   WiFiEngine_SetTxPktWindow(hp->txPktWinSize);

   WiFiEngine_CommitPDUSizeAlignment(); 

#ifdef USE_IF_REINIT
   /* Check once per second. */
   WiFiEngine_SetActivityTimeout(registry.network.basic.activityTimeout, 1000);
#endif 

   wifiEngineState.driver_start_ts = DriverEnvironment_GetTimestamp_msec();

   DE_TRACE_STATIC(TR_INITIALIZE, "Done!\n");

   return WIFI_ENGINE_SUCCESS;
}
コード例 #6
0
int main(int argc, char **argv) 
{
  const char      *hmmfile;	/* file to read HMMs from                  */
  HMMFILE         *hmmfp;       /* opened hmmfile for reading              */
  const char      *seqfile;     /* file to read target sequence from       */ 
  char           **rseq;        /* raw, unaligned sequences                */ 
  SQINFO          *sqinfo;      /* info associated with sequences          */
  char           **dsq;         /* digitized raw sequences                 */
  int              nseq;        /* number of sequences                     */  
  char           **aseq;        /* aligned sequences                       */
  AINFO            ainfo;       /* alignment information                   */
  float           *wgt;         /* per-sequence weights                    */
  int              i;
  struct plan7_s    *hmm;       /* HMM to align to                         */ 
  struct p7trace_s **tr;        /* traces for aligned sequences            */

  int   be_quiet;		/* TRUE to suppress verbose banner          */
  int   matchonly;		/* TRUE to show only match state syms       */
  const char *outfile;          /* optional alignment output file           */
  FILE *ofp;                    /* handle on alignment output file          */
  AjPFile ajwithali;          /* name of additional alignment file to align */
  AjPFile ajmapali;           /* name of additional alignment file to map   */
  AjBool ajmatch=ajFalse;
  AjPFile outf=NULL;
  AjPStr  outfname=NULL;
  AjPFile inf=NULL;
  AjPStr  infname=NULL;
  AjPSeqset seqset=NULL;
  AjPStr  ajseqfile=NULL;
  char*  mapali=NULL;
  char*  withali=NULL;
  
#ifdef MEMDEBUG
  unsigned long histid1, histid2, orig_size, current_size;
  orig_size = malloc_inuse(&histid1);
  fprintf(stderr, "[... memory debugging is ON ...]\n");
#endif

  /*********************************************** 
   * Parse command line
   ***********************************************/
  
  matchonly = FALSE;
  outfile   = NULL;
  be_quiet  = FALSE;
  withali   = NULL;
  mapali    = NULL;

  embInitPV("ohmmalign",argc,argv,"HMMER",VERSION);

  ajmatch = ajAcdGetBoolean("matchonly");
  if(ajmatch)
      matchonly=TRUE;
  else
      matchonly=FALSE;



  ajmapali = ajAcdGetInfile("mapalifile");
  if (ajmapali)
      mapali = ajCharNewS(ajFileGetNameS(ajmapali));
  ajFileClose(&ajmapali);
  ajwithali = ajAcdGetInfile("withalifile");
  if (ajwithali)
      withali = ajCharNewS(ajFileGetNameS(ajwithali));
  ajFileClose(&ajwithali);

  be_quiet=TRUE;



  outf = ajAcdGetOutfile("outfile");
  outfname = ajStrNewC((char *)ajFileGetNameC(outf));
  if(*ajStrGetPtr(outfname)>31)
      ajFileClose(&outf);
  outfile = ajStrGetPtr(outfname);

  inf = ajAcdGetInfile("hmmfile");
  infname = ajStrNewC((char *)ajFileGetNameC(inf));
  ajFileClose(&inf);
  hmmfile = ajStrGetPtr(infname);

  
  seqset = ajAcdGetSeqset("sequences");
  ajseqfile = ajStrNewC(ajStrGetPtr(seqset->Filename));
  seqfile = ajStrGetPtr(ajseqfile);
  

 /*********************************************** 
  * Open HMM file (might be in HMMERDB or current directory).
  * Read a single HMM from it.
  * 
  * Currently hmmalign disallows the J state and
  * only allows one domain per sequence. To preserve
  * the S/W entry information, the J state is explicitly
  * disallowed, rather than calling a Plan7*Config() function.
  * this is a workaround in 2.1 for the 2.0.x "yo!" bug.
  ***********************************************/

  if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL)
    ajFatal("Failed to open HMM file %s\n", hmmfile);
  if (!HMMFileRead(hmmfp, &hmm)) 
    ajFatal("Failed to read any HMMs from %s\n", hmmfile);
  HMMFileClose(hmmfp);
  if (hmm == NULL) 
    ajFatal("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile);
  hmm->xt[XTE][MOVE] = 1.;	      /* only 1 domain/sequence ("global" alignment) */
  hmm->xt[XTE][LOOP] = 0.;
  P7Logoddsify(hmm, TRUE);
				/* do we have the map we might need? */
  if (mapali != NULL && ! (hmm->flags & PLAN7_MAP))
    ajFatal("HMMER: HMM file %s has no map; you can't use --mapali.", hmmfile);

  /*********************************************** 
   * Open sequence file in current directory.
   * Read all seqs from it.
   ***********************************************/
/*
  if (! SeqfileFormat(seqfile, &format, NULL))
    switch (squid_errno) {
    case SQERR_NOFILE: 
      ajFatal("Sequence file %s could not be opened for reading", seqfile);
    case SQERR_FORMAT: 
    default:           
      ajFatal("Failed to determine format of sequence file %s", seqfile);
    }
  if (! ReadMultipleRseqs(seqfile, format, &rseq, &sqinfo, &nseq))
    ajFatal("Failed to read any sequences from file %s", seqfile);
*/

  emboss_rseqs(seqset,&rseq,&sqinfo,&nseq);

  /*********************************************** 
   * Show the banner
   ***********************************************/

  be_quiet=TRUE;
  if (! be_quiet) 
    {
/*      Banner(stdout, banner); */
      printf(   "HMM file:             %s\n", hmmfile);
      printf(   "Sequence file:        %s\n", seqfile);
      printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n");
    }

  /*********************************************** 
   * Do the work
   ***********************************************/

  /* Allocations and initializations.
   */
  dsq = MallocOrDie(sizeof(char *) * nseq);
  tr  = MallocOrDie(sizeof(struct p7trace_s *) * nseq);

  /* Align each sequence to the model, collect traces
   */
  for (i = 0; i < nseq; i++)
    {
      dsq[i] = DigitizeSequence(rseq[i], sqinfo[i].len);

      if (P7ViterbiSize(sqinfo[i].len, hmm->M) <= RAMLIMIT)
	(void) P7Viterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i]));
      else
	(void) P7SmallViterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i]));
    }

  /* Include an aligned alignment, if desired.
   */
  if (mapali != NULL)
    include_alignment(mapali, hmm, TRUE, &rseq, &dsq, &sqinfo, &tr, &nseq);
  if (withali != NULL) 
    include_alignment(withali, hmm, FALSE, &rseq, &dsq, &sqinfo, &tr, &nseq);

  /* Turn traces into a multiple alignment
   */ 
  wgt = MallocOrDie(sizeof(float) * nseq);
  FSet(wgt, nseq, 1.0);
  P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, matchonly,
		     &aseq, &ainfo);

  /*********************************************** 
   * Output the alignment
   ***********************************************/

  if (outfile != NULL && (ofp = fopen(outfile, "w")) != NULL)
    {
      WriteSELEX(ofp, aseq, &ainfo, 50);
      printf("Alignment saved in file %s\n", outfile);
      fclose(ofp);
    }
  else
    WriteSELEX(stdout, aseq, &ainfo, 50);

  /*********************************************** 
   * Cleanup and exit
   ***********************************************/
  
  for (i = 0; i < nseq; i++) 
    {
      P7FreeTrace(tr[i]);
      FreeSequence(rseq[i], &(sqinfo[i]));
      free(dsq[i]);
    }
  FreeAlignment(aseq, &ainfo);
  FreePlan7(hmm);
  free(sqinfo);
  free(rseq);
  free(dsq);
  free(wgt);
  free(tr);

  SqdClean();

  ajStrDel(&outfname);
  ajStrDel(&infname);
  ajStrDel(&ajseqfile);
  

#ifdef MEMDEBUG
  current_size = malloc_inuse(&histid2);
  if (current_size != orig_size) malloc_list(2, histid1, histid2);
  else fprintf(stderr, "[No memory leaks.]\n");
#endif

  ajSeqsetDel(&seqset);
  ajFileClose(&ajwithali);
  ajFileClose(&ajmapali);

  embExit();
  
  return 0;
}
コード例 #7
0
ファイル: clid.c プロジェクト: AkankshaGovil/Automation
int
handle_command(char *buffer)
{
	int rc = 1;
	char *op;
	int cmdtype;
	static unsigned long mark;

	if (ExtractArg(buffer, &op, &buffer) < 0)
	{
		return -1;
	}

	cmdtype = type_command(op);

	switch (cmdtype)
	{
		case COMMAND_GET:
			handle_get_command(buffer);
			break;
		case COMMAND_SET:
			handle_set_command(buffer);
			break;
		case COMMAND_RESET:
			handle_reset_command(buffer);
			break;
		case COMMAND_BYE:
			handle_bye_command(buffer);
			rc = 0;
			break;
		case COMMAND_CLI:
			handle_cli_command(buffer);
			break;
		case COMMAND_MEMSTART:
#ifdef _DMALLOC_
		dmalloc_message("starting new log");
		mark = dmalloc_mark();
#elif _DBMALLOC_ 
			if(malloc_chain_check(0)!=0)
			{
				int fd;
                fd = open("/usr/local/nextone/logs/malloc.inuse", O_CREAT|O_RDWR
);
                malloc_dump(fd );
                close(fd);

			}
			orig_size = malloc_inuse(&histid1);
#endif
            break;	
		case COMMAND_MEMSTOP:
#ifdef _DMALLOC_
		dmalloc_log_changed(mark, 1, 0, 1);
		dmalloc_message("end of log");
#elif _DBMALLOC_ 
			current_size = malloc_inuse(&histid2);

            if(current_size != orig_size)
            {
				int fd;

                fd = open("/usr/local/nextone/logs/malloc.inuse", O_CREAT|O_RDWR
);
                malloc_list(fd, histid1, histid2);
                close(fd);
            }
#endif
            break;

		case COMMAND_NONE:
		default:
			break;
	}

	return rc;
}