Пример #1
0
/* ---------------------------------------------------------------------------
 * free memory used by PCB
 */
void
FreePCBMemory (PCBTypePtr PCBPtr)
{
  int i;

  if (PCBPtr)
    {
      MYFREE (PCBPtr->Name);
      MYFREE (PCBPtr->Filename);
      MYFREE (PCBPtr->PrintFilename);
      if (PCBPtr->Data)
	FreeDataMemory (PCBPtr->Data);
      MYFREE (PCBPtr->Data);
      /* release font symbols */
      for (i = 0; i <= MAX_FONTPOSITION; i++)
	MYFREE (PCBPtr->Font.Symbol[i].Line);
      FreeLibraryMemory (&PCBPtr->NetlistLib);
      FreeAttributeListMemory (&PCBPtr->Attributes);
      /* clear struct */
      memset (PCBPtr, 0, sizeof (PCBType));
    }
  else
    {
      fprintf (stderr, "Warning:  Tried to FreePCBMemory(null)\n");
    }
}
Пример #2
0
int aln_pair_align(FILE *fp1, FILE *fp2, AlnParam *ap, int type, int misc_flag)
{
	seq_t seq1, seq2;
	int len1, len2, n;
	char name1[MAX_NAME_LEN], name2[MAX_NAME_LEN];
	path_t *pt, *pp;
	AlnAln *aa;

	INIT_SEQ(seq1); INIT_SEQ(seq2);

	for (n = 0; ; ++n) {
		len1 = read_fasta(fp1, &seq1, name1, 0);
		len2 = read_fasta(fp2, &seq2, name2, 0);
		if (len1 < 0 || len2 < 0) break;
		aa = aln_align((char*)seq1.s, (char*)seq2.s, ap, type);
		pp = aa->path; pt = aa->path + aa->path_len - 1;
		printf(">%s\t%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\n", name1, len1, pt->i, pp->i,
				name2, len2, pt->j, pp->j, aa->score);
		if (aa->out1) printf("%s\n", aa->out1);
		if (aa->outm) printf("%s\n", aa->outm);
		if (aa->out2) printf("%s\n", aa->out2);
		if (type != ALN_BOUND_ALIGN) printf("//\n");
		fflush(stdout);
		if (misc_flag)
			aln_output_segment((char*)seq1.s, (char*)seq2.s, aa->path, aa->path_len, name1, name2);
		aln_free_AlnAln(aa);
	}
	MYFREE(seq1.s); MYFREE(seq2.s);
	return n;
}
Пример #3
0
void *_tc_recdecode(const void *ptr, int size, int *sp, void *op){
  if(!_tc_lzo_init){
    if(lzo_init() != LZO_E_OK) return NULL;
    _tc_lzo_init = false;
  }
  lzo_bytep buf;
  lzo_uint bsiz;
  int rat = 6;
  while(true){
    bsiz = (size + 256) * rat + 3;
    buf = MYMALLOC(bsiz + 1);
    if(!buf) return NULL;
    int rv = lzo1x_decompress_safe((lzo_bytep)ptr, size, buf, &bsiz, NULL);
    if(rv == LZO_E_OK){
      break;
    } else if(rv == LZO_E_OUTPUT_OVERRUN){
      MYFREE(buf);
      rat *= 2;
    } else {
      MYFREE(buf);
      return NULL;
    }
  }
  buf[bsiz] = '\0';
  if(sp) *sp = bsiz;
  return (char *)buf;
}
Пример #4
0
int adios_copyspec_init_from_intersection(adios_subvolume_copy_spec *copy_spec, int ndim,
                                          const uint64_t *dst_dims, const uint64_t *dst_goffsets,
                                          const uint64_t *src_dims, const uint64_t *src_goffsets) {
    // Initialize with number of dimensions and source/destination dimensions
    // Offsets and subvolume dimension are unknown at this time
    // Arg order:
    // copyspec, ndim, subv_dims
    // dst_dims, dst_subv_offsets
    // src_dims, src_subv_offsets
    adios_copyspec_init_from_bufs(copy_spec, ndim, NULL,
                                  dst_dims, NULL,
                                  src_dims, NULL);

    uint64_t *subv_dims = malloc(ndim * sizeof(uint64_t));
    uint64_t *dst_subv_offsets = malloc(ndim * sizeof(uint64_t));
    uint64_t *src_subv_offsets = malloc(ndim * sizeof(uint64_t));

    // Compute the intersection to compute in the rest of the information
    const int intersects =
        intersect_volumes(ndim, dst_dims, dst_goffsets, src_dims, src_goffsets,
                          subv_dims, NULL,
                          dst_subv_offsets, src_subv_offsets);

    if (intersects) {
    	copy_spec->subv_dims = subv_dims;
    	copy_spec->dst_subv_offsets = dst_subv_offsets;
    	copy_spec->src_subv_offsets = src_subv_offsets;
    } else {
    	MYFREE(subv_dims);
    	MYFREE(dst_subv_offsets);
    	MYFREE(src_subv_offsets);
    }

    return intersects;
}
Пример #5
0
void pw_ccp(PwParam *p, Mapfile *mapfile, int chr, int chrlen){
  int i;

  printf("Making cross-correlation profile...\n");
  TYPE_WIGARRAY *plus  = chrarray_new(mapfile, chr, chrlen, STRAND_PLUS);
  TYPE_WIGARRAY *minus = chrarray_new(mapfile, chr, chrlen, STRAND_MINUS);

  TYPE_WIGARRAY qnt99 = calc_qnt(plus, chrlen, 0.99);
  for(i=0; i<chrlen; i++){
    if(plus[i]  > qnt99) plus[i]  = qnt99;
    if(minus[i] > qnt99) minus[i] = qnt99;
  }

  char *outputfile = alloc_str_new(p->output_dir, strlen(p->output_prefix) +100);
  sprintf(outputfile, "%s/%s.ccp.xls", p->output_dir, p->output_prefix);
  FILE *OUT = my_fopen(outputfile, FILE_MODE_WRITE);
  fprintf(OUT, "strand-shift\tcross-correlation\n");
  double cc=0;
  int start=1000;
  int num=chrlen-2500;
  for(i=-500; i<1500; i+=5){
    cc = calc_corr(plus + start, minus + start + i, num);
    fprintf(OUT, "%d\t%f\n", i, cc);
  }
  fclose(OUT);
  printf("Output to %s.\n",outputfile);

  MYFREE(outputfile);
  MYFREE(plus);
  MYFREE(minus);
  return;
}
Пример #6
0
/* ---------------------------------------------------------------------------
 * frees memory used by an element
 */
void
FreeElementMemory (ElementTypePtr Element)
{
  if (Element)
    {
      ELEMENTNAME_LOOP (Element);
      {
	MYFREE (textstring);
      }
      END_LOOP;
      PIN_LOOP (Element);
      {
	MYFREE (pin->Name);
	MYFREE (pin->Number);
      }
      END_LOOP;
      PAD_LOOP (Element);
      {
	MYFREE (pad->Name);
	MYFREE (pad->Number);
      }
      END_LOOP;
      MYFREE (Element->Pin);
      MYFREE (Element->Pad);
      MYFREE (Element->Line);
      MYFREE (Element->Arc);
      FreeAttributeListMemory (&Element->Attributes);
      memset (Element, 0, sizeof (ElementType));
    }
}
Пример #7
0
// Populates data transform information about a given variable into an ADIOS_VARTRANSFORM struct
// Return NULL if failed
ADIOS_VARTRANSFORM *  adios_inq_var_transform(const ADIOS_FILE *fp, const ADIOS_VARINFO *varinfo){
	// Get the global metadata
	ADIOS_TRANSINFO* tinfo = common_read_inq_transinfo(fp, varinfo);
	if (tinfo == NULL)
		return NULL;

	// Get the per-PG metadata
	common_read_inq_trans_blockinfo(fp, varinfo, tinfo);
	if (tinfo->orig_blockinfo == NULL || tinfo->transform_metadatas == NULL)
		return NULL;

	// Load all the metadata into the ADIOS_VARTRANSFORM datastructure
	ADIOS_VARTRANSFORM *vartransform = (ADIOS_VARTRANSFORM*) malloc(sizeof(ADIOS_VARTRANSFORM));
	*vartransform = (ADIOS_VARTRANSFORM){
		.varid = varinfo->varid,
		.sum_nblocks = varinfo->sum_nblocks,
		.transform_type = tinfo->transform_type,
		.should_free_transform_metadata = tinfo->should_free_transform_metadata,
		.transform_metadatas = tinfo->transform_metadatas
	};

	// Transfer ownership of the transform_metadatas array to the new struct, then free the struct
	tinfo->transform_metadatas = NULL;
	common_read_free_transinfo(varinfo, tinfo);

	return vartransform;
}

#define MYFREE(p) {if (p){ free((void*)(p)); (p) = NULL; }}
void adios_free_var_transform(ADIOS_VARTRANSFORM *vartransform) {
	if (vartransform->transform_metadatas) {
		if (vartransform->should_free_transform_metadata) {
			int i;
			for (i = 0; i < vartransform->sum_nblocks; i++)
				MYFREE(vartransform->transform_metadatas[i].content);
		}
		MYFREE(vartransform->transform_metadatas);
	}
	MYFREE(vartransform);
}


void adios_free_pg_intersections(ADIOS_PG_INTERSECTIONS **intersections){
	ADIOS_PG_INTERSECTIONS * intsec = *intersections;
	int i = 0;
	for(i=0; i < intsec->npg; i++){
		ADIOS_PG_INTERSECTION inter = intsec->intersections[i];
		common_read_selection_delete(inter.pg_bounds_sel);
		common_read_selection_delete(inter.intersection_sel);
	}
	intsec->npg = 0;
	intsec->intersections = NULL;
	MYFREE(*intersections);
}
Пример #8
0
static void free_mapfile_chr(PwParam *pwparam, Mapfile *p, int chr){
  Strand strand;
  for(strand=0; strand<STRANDNUM; strand++){
    MYFREE(p->readarray[chr][strand].F3);
    if(pwparam->rtype==READTYPE_PAIR) MYFREE(p->readarray[chr][strand].F5);
    MYFREE(p->readarray[chr][strand].weight);
    MYFREE(p->readarray[chr][strand].delete);
    if(pwparam->bedfilename) MYFREE(p->readarray[chr][strand].ignore);
  }
  MYFREE(p->readarray[chr]);
  return;
}
Пример #9
0
/* ---------------------------------------------------------------------------
 * frees memory used by a polygon
 */
void
FreePolygonMemory (PolygonTypePtr Polygon)
{
  if (Polygon)
    {
      MYFREE (Polygon->Points);
      MYFREE (Polygon->HoleIndex);
      if (Polygon->Clipped)
	poly_Free (&Polygon->Clipped);
      poly_FreeContours (&Polygon->NoHoles);
      memset (Polygon, 0, sizeof (PolygonType));
    }
}
Пример #10
0
void
lm_free_status(lm_status_t* status) {
    if (!status)
        return;

    if (status->free_blk_info)
        MYFREE(status->free_blk_info);

    if (status->alloc_blk_info)
        MYFREE(status->alloc_blk_info);

    MYFREE(status);
}
Пример #11
0
/*
 * Free cipher CTX if it is dynamically allocated. Do not use
 * if cipher ctx is statically allocated as in OpenSSL implementation of
 * GOST hash algroritm
 *
 */
void done_gost_hash_ctx(gost_hash_ctx * ctx)
{
    /*
     * No need to use gost_destroy, because cipher keys are not really secret
     * when hashing
     */
    MYFREE(ctx->cipher_ctx);
}
Пример #12
0
static void
netlist_style (LibraryMenuType *net, const char *style)
{
  if (net->Style)
    MYFREE (net->Style);
  if (style)
    net->Style = MyStrdup ((char *)style, "Netlist(Style)");
}
Пример #13
0
/* ---------------------------------------------------------------------------
 * frees memory used by a box list
 */
void
FreeBoxListMemory (BoxListTypePtr Boxlist)
{
  if (Boxlist)
    {
      MYFREE (Boxlist->Box);
      memset (Boxlist, 0, sizeof (BoxListType));
    }
}
Пример #14
0
/* ---------------------------------------------------------------------------
 * frees memory used by a subnet 
 */
void
FreeNetMemory (NetTypePtr Net)
{
  if (Net)
    {
      MYFREE (Net->Connection);
      memset (Net, 0, sizeof (NetType));
    }
}
Пример #15
0
void convert_bedGraph_to_bigWig(char *outputfile, char *output_prefix, char *gtfile){
  printf("convert to bigWig format...\n");
  char *command = alloc_str_new(outputfile, strlen(gtfile) + strlen(output_prefix) + 1024);
  sprintf(command, "bedGraphToBigWig %s.bedGraph %s %s.bw", output_prefix, gtfile, output_prefix);
  LOG("%s\n", command);
  my_system(command);
  remove(outputfile);
  MYFREE(command);
  return;
}
Пример #16
0
static TYPE_WIGARRAY calc_qnt(TYPE_WIGARRAY *array, int chrlen, double per){
  int i, num=0;
  TYPE_WIGARRAY qnt=0;
  TYPE_WIGARRAY *sortarray = (TYPE_WIGARRAY *)my_calloc(chrlen, sizeof(TYPE_WIGARRAY), "sortarray");
  for(i=0; i<chrlen; i++){
    if(array[i]) sortarray[num++] = array[i];
  }
  qsort(sortarray, num, sizeof(TYPE_WIGARRAY), comp_wig);
  qnt = sortarray[(int)(num*per)];
  MYFREE(sortarray);
  return qnt;
}
Пример #17
0
// ----------------------------------------------------------------------
// Free all files
// ----------------------------------------------------------------------
VOID FreeAllFileContents(LPFILECONTENT lpFC) 
{
	LPFILECONTENT lpBrotherFC;

	for (; NULL != lpFC; lpFC = lpBrotherFC) {
		// Save pointer in local variable
		lpBrotherFC = lpFC->lpBrotherFC;

		// Free file name
		if (NULL != lpFC->lpszFileName) {
			MYFREE(lpFC->lpszFileName);
		}

		// If the entry has childs, then do a recursive call for the first child
		if (NULL != lpFC->lpFirstSubFC) {
			FreeAllFileContents(lpFC->lpFirstSubFC);
		}

		// Free entry itself
		MYFREE(lpFC);
	}
}
Пример #18
0
static void
transfer_names(ElementTypePtr old_element, ElementTypePtr new_element)
{
  PAD_OR_PIN_LOOP_HYG(old_element, _old);
  {
    const char* old_name = pad_or_pin_name(&pp_old);
    PAD_OR_PIN_LOOP_HYG(new_element, _new);
    {
      if (pad_or_pin_number_cmp(&pp_old, &pp_new) == 0) {
        if (pp_new.pad) {
          MYFREE(pp_new.pad->Name);
          pp_new.pad->Name = MyStrdup((char*)old_name, "transfer_names()");
        } else if (pp_new.pin) {
          MYFREE(pp_new.pin->Name);
          pp_new.pin->Name = MyStrdup((char*)old_name, "transfer_names()");
        }
      }
    }
    END_LOOP;
  }
  END_LOOP;
}
Пример #19
0
static void VFUN(add2Vector)(VECTORNAME* v, VECTORTYPE val) {
  if ( (v->size+1) >= v->max_size ) {
    int i;
    VECTORTYPE *new_values;

    v->max_size *= 2;
    new_values = (VECTORTYPE*)MYALLOC(v->max_size*sizeof(VECTORTYPE));
    for(i=0; i<v->size; i++)
  	new_values[i] = v->values[i];
    MYFREE(v->values);
    v->values = new_values;
  }
  v->values[v->size++] = val;
}
Пример #20
0
/* ---------------------------------------------------------------------------
 * frees memory used by a net list
 */
void
FreeNetListListMemory (NetListListTypePtr Netlistlist)
{
  if (Netlistlist)
    {
      NETLIST_LOOP (Netlistlist);
      {
	FreeNetListMemory (netlist);
      }
      END_LOOP;
      MYFREE (Netlistlist->NetList);
      memset (Netlistlist, 0, sizeof (NetListListType));
    }
}
Пример #21
0
void calc_FRiP(PwParam *p, Mapfile *mapfile, RefGenome *g){
  int i,j, chr;
  long nread;
  Strand strand;
  struct seq *seq;
  int s,e;
  char *array = NULL;

  /* count reads */
  for(chr=1; chr<g->chrnum; chr++){  
    array = makearray_inbed(&(p->enrichfile->chr[chr]), (int)g->chr[chr].len);
    if(!array) continue;

    for(strand=0; strand<STRANDNUM; strand++){
      seq = &(mapfile->chr[chr].seq[strand]);
      nread = seq->n_read_infile;
      for(i=0; i<nread; i++){
	if(p->pcrfilter && mapfile->readarray[chr][strand].delete[i]) continue;

	/* readの両端をs,eに格納 */
	  get_start_end_of_read(p, mapfile, &s, &e, chr, i, strand, g->chr[chr].len, __FUNCTION__);
	  //	  printf("%s, %d, %d-, %d, %d, %s\n", g->chr[chr].name, i, s, e, mapfile->readarray[chr][strand].F3[i], str_strand[strand]);
	  //	  printf("%s, %d, %d-%d, %d, %d, %s\n", g->chr[chr].name, i, s, e, mapfile->readarray[chr][strand].F3[i], mapfile->readarray[chr][strand].F5[i], str_strand[strand]);
	for(j=s; j<=e; j++){
	  if(array[j]){
	    mapfile->readarray[chr][strand].ignore[i] = true;
	    mapfile->chr[chr].n_read_inbed++;
	    break;
	  }
	}
      }
    }
    /* add to genome */
    mapfile->genome->n_read_inbed += mapfile->chr[chr].n_read_inbed;
    MYFREE(array);
  }

  /* calc FRiP */
  for(chr=1; chr<g->chrnum; chr++){
    if(p->pcrfilter) nread = mapfile->chr[chr].both.n_read_nonred;
    else             nread = mapfile->chr[chr].both.n_read_infile;
    mapfile->chr[chr].FRiP = mapfile->chr[chr].n_read_inbed / (double)nread;
  }
  if(p->pcrfilter) nread = mapfile->genome->both.n_read_nonred;
  else             nread = mapfile->genome->both.n_read_infile;
  mapfile->genome->FRiP  = mapfile->genome->n_read_inbed / (double)nread;
  
  return;
}
Пример #22
0
// ----------------------------------------------------------------------
// Display snapshot overview to standard output
// ----------------------------------------------------------------------
VOID DisplayShotInfo(LPSNAPSHOT lpShot) 
{
	LPTSTR lpszInfoBox;
	lpszInfoBox = MYALLOC0(SIZEOF_INFOBOX * sizeof(TCHAR));
	_sntprintf(lpszInfoBox, SIZEOF_INFOBOX, TEXT("    %s %u\n    %s %u\n    %s %u\n    %s %u\n\0"),
		asLangTexts[iszTextKey].lpszText, lpShot->stCounts.cKeys,
		asLangTexts[iszTextValue].lpszText, lpShot->stCounts.cValues,
		asLangTexts[iszTextDir].lpszText, lpShot->stCounts.cDirs,
		asLangTexts[iszTextFile].lpszText, lpShot->stCounts.cFiles
		);
	lpszInfoBox[SIZEOF_INFOBOX - 1] = (TCHAR)'\0';  // safety NULL char
	printf("  > %s\n", "Snapshot overview:");
	wprintf(L"%s", lpszInfoBox);
	MYFREE(lpszInfoBox);
}
Пример #23
0
void make_bedGraph(RefGenome *g, TYPE_WIGARRAY *array, char *outputfile, char *prefix, int binsize, int binnum, int chr, int showzero){
  int i,e;
  if(chr==1) remove_file(outputfile);
  FILE *OUT = my_fopen(outputfile, FILE_MODE_A);
  for(i=0; i<binnum; i++){
    if(i==binnum -1) e = g->chr[chr].len-1; else e = (i+1)*binsize;
    if(showzero || array[i]) fprintf(OUT, "%s %d %d %.3f\n", g->chr[chr].name, i*binsize, e, WIGARRAY2VALUE(array[i]));
  }
  fclose(OUT);

  if(chr == g->chrnum-1){
      char *command = alloc_str_new(outputfile, strlen(outputfile) + 1024);
      sprintf(command, "sort -k1,1 -k2,2n %s > %s.sort", outputfile, outputfile);
      LOG("%s\n", command);
      my_system(command);
      char *tempfile = alloc_str_new(outputfile, 1024);
      sprintf(tempfile, "%s.temp", outputfile);
      OUT = my_fopen(tempfile, FILE_MODE_A);
      fprintf(OUT, "browser position %s:%ld-%ld\n", g->chr[1].name, g->chr[1].len/3, min(g->chr[1].len/3+1000000, g->chr[1].len-1));
      fprintf(OUT, "browser hide all\n");
      fprintf(OUT, "browser pack refGene encodeRegions\n");
      fprintf(OUT, "browser full altGraph\n");
      fprintf(OUT, "track type=bedGraph name=\"%s\" description=\"Merged tag counts for every %d bp\" visibility=full\n", prefix, binsize);
      fclose(OUT);
      sprintf(command, "cat %s %s.sort > %s", tempfile, outputfile, outputfile);
      LOG("%s\n", command);
      my_system(command);
      sprintf(command, "rm %s.sort %s", outputfile, tempfile);
      LOG("%s\n", command);
      my_system(command);

      MYFREE(command);
      MYFREE(tempfile);
  }
  return;
}
Пример #24
0
void output_bindata(char *dir, char *prefix, RefGenome *g, TYPE_WIGARRAY *array, char *gtfile, int binsize, int binnum, int chr, PWfile_Type wtype, int showzero){
  char *output_prefix = alloc_str_new(dir, strlen(prefix) + 1024);
  if(wtype==TYPE_BEDGRAPH || wtype==TYPE_BIGWIG) sprintf(output_prefix, "%s/%s.%d", dir, prefix, binsize);
  else sprintf(output_prefix, "%s/%s_%s.%d", dir, prefix, g->chr[chr].name, binsize);
  char *outputfilename = alloc_str_new(output_prefix, 200);

  if(wtype==TYPE_BINARY){
    sprintf(outputfilename, "%s.bin", output_prefix);
    make_binary(array, outputfilename, binnum);
  }
  else if(wtype==TYPE_BEDGRAPH || wtype==TYPE_BIGWIG){
    sprintf(outputfilename, "%s.bedGraph", output_prefix);
    make_bedGraph(g, array, outputfilename, output_prefix, binsize, binnum, chr, showzero);
    if(chr == g->chrnum-1 && wtype==TYPE_BIGWIG) convert_bedGraph_to_bigWig(outputfilename, output_prefix, gtfile);
  }
  else if(wtype==TYPE_COMPRESSWIG || wtype==TYPE_UNCOMPRESSWIG){
    sprintf(outputfilename, "%s.wig", output_prefix);
    make_wig(g, array, outputfilename, prefix, binsize, binnum, chr, wtype, showzero);
  }

  MYFREE(output_prefix);
  MYFREE(outputfilename);
  return;
}
Пример #25
0
void
lm_fini_page_alloc(void) {
    if (alloc_info) {
        rb_tree_t* free_blks = &alloc_info->free_blks[0];
        int i, e;
        for (i = 0, e = MAX_ORDER; i < e; i++)
            rbt_fini(free_blks + i);

        rbt_fini(&alloc_info->alloc_blks);

        MYFREE(alloc_info);
        alloc_info = 0;
    }

    bc_fini();
}
Пример #26
0
// ----------------------------------------------------------------------
// Free all head files
// ----------------------------------------------------------------------
VOID FreeAllHeadFiles(LPHEADFILE lpHF)
{
	LPHEADFILE lpBrotherHF;

	for (; NULL != lpHF; lpHF = lpBrotherHF) {
		// Save pointer in local variable
		lpBrotherHF = lpHF->lpBrotherHF;

		// If the entry has childs, then do a recursive call for the first child
		if (NULL != lpHF->lpFirstFC) {
			FreeAllFileContents(lpHF->lpFirstFC);
		}

		// Free entry itself
		MYFREE(lpHF);
	}
}
Пример #27
0
void *_tc_recencode(const void *ptr, int size, int *sp, void *op){
  if(!_tc_lzo_init){
    if(lzo_init() != LZO_E_OK) return NULL;
    _tc_lzo_init = false;
  }
  lzo_bytep buf = MYMALLOC(size + (size >> 4) + 80);
  if(!buf) return NULL;
  lzo_uint bsiz;
  char wrkmem[LZO1X_1_MEM_COMPRESS];
  if(lzo1x_1_compress((lzo_bytep)ptr, size, buf, &bsiz, wrkmem) != LZO_E_OK){
    MYFREE(buf);
    return NULL;
  }
  buf[bsiz] = '\0';
  *sp = bsiz;
  return (char *)buf;
}
Пример #28
0
static void
transfer_text(ElementTypePtr old_element, ElementTypePtr new_element)
{
  int i;
  for (i = 0; i < MAX_ELEMENTNAMES; i++) {
    TextTypePtr old_text = &old_element->Name[i];
    TextTypePtr new_text = &new_element->Name[i];
    MYFREE(new_text->TextString);
    new_text->X = old_text->X;
    new_text->Y = old_text->Y;
    new_text->Direction = old_text->Direction;
    new_text->Flags = old_text->Flags;
    new_text->Scale = old_text->Scale;
    new_text->TextString =
      ((old_text->TextString && *old_text->TextString) ?
       MyStrdup(old_text->TextString, "transfer_text()") : NULL);
  }
}
Пример #29
0
void adios_copyspec_free(adios_subvolume_copy_spec **copy_spec_ptr, int free_buffers) {
    adios_subvolume_copy_spec *copy_spec = *copy_spec_ptr;
    if (free_buffers) {
        MYFREE(copy_spec->subv_dims);
        MYFREE(copy_spec->dst_dims);
        MYFREE(copy_spec->dst_subv_offsets);
        MYFREE(copy_spec->src_dims);
        MYFREE(copy_spec->src_subv_offsets);
    }
    memset(copy_spec, 0, sizeof(adios_subvolume_copy_spec));

    MYFREE(*copy_spec_ptr);
}
Пример #30
0
static TYPE_WIGARRAY calc_qnt(TYPE_WIGARRAY *array, int binnum, double per){
  int i, num=0;
  for(i=0; i<binnum; i++){
    if(array[i]) num++;
  }

  TYPE_WIGARRAY *sortarray = (TYPE_WIGARRAY *)my_calloc(num, sizeof(TYPE_WIGARRAY), "sortarray");
  num=0;
  for(i=0; i<binnum; i++){
    if(array[i]) sortarray[num++] = array[i];
  }

  qsort(sortarray, num, sizeof(TYPE_WIGARRAY), comparray);
  TYPE_WIGARRAY qnt = sortarray[(int)(num*per)];
  MYFREE(sortarray);

  if(qnt<=1000) qnt=2000;
  
  return qnt;
}