当前位置: 首页>>代码示例>>C++>>正文


C++ MemNew函数代码示例

本文整理汇总了C++中MemNew函数的典型用法代码示例。如果您正苦于以下问题:C++ MemNew函数的具体用法?C++ MemNew怎么用?C++ MemNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MemNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadPubMedRecords

static void ReadPubMedRecords (LinkSetPtr lsp, FILE *fp)

{
  Int4                  count;
  Int2                  num;
  MedlineEntryPtr PNTR  list;  /* see <objmedli.h> */
  MedlineEntryPtr       mep;

  if (lsp == NULL || lsp->num == 0 || lsp->uids == NULL) return;
  list = (MedlineEntryPtr PNTR) MemNew (lsp->num * sizeof (MedlineEntryPtr));
  if (list != NULL) {

    /* EntrezMedlineEntryListGet get a maximum of 32767 records at once */
    num = EntrezMedlineEntryListGet (list, lsp->num, lsp->uids, FALSE);

    for (count = 0; count < num; count++) {
      mep = list [count];
      if (mep != NULL) {
        /* the following call saves the record in traditional MEDLINE format */
        if (MedlineEntryToDataFile (mep, fp)) {
          fprintf (fp, "\n\n");
        }
      }
    }

    for (count = 0; count < lsp->num; count++) {
      list [count] = MedlineEntryFree (list [count]);
    }
    MemFree (list);
  }
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:31,代码来源:fetchent.c

示例2: SLRI_SSGetWholeString

/* Returns a concatenation of all stack contents */
CharPtr
SLRI_SSGetWholeString(SLRI_SStackPtr ssp)
{
  SLRI_SStackItemPtr ssipCurr = NULL;
  CharPtr wholeString = NULL;

  if (ssp == NULL) {
    ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSGetWholeString: stack pointer is NULL");
    return(NULL);
  }

  if (SLRI_SSIsEmpty(ssp)) {
    return(NULL);
  }

  wholeString = MemNew((ssp->totalStackSize + 1) * sizeof(Char));

  /* Initialize wholeString with first item */
  StringCpy(wholeString, ssp->bottom->string);

  /* Cycle through rest of stack to get remaining items */
  ssipCurr = ssp->bottom->next;
  while (ssipCurr != NULL) {
    StringCat(wholeString, ssipCurr->string);
    ssipCurr = ssipCurr->next;
  }

  return(wholeString);
}
开发者ID:iandonaldson,项目名称:slri,代码行数:30,代码来源:slri_sstack.c

示例3: GetProtListCallback

static void GetProtListCallback (BioseqPtr bsp, Pointer userdata)
{
  ValNodePtr PNTR   pList;
  SeqFeatPtr        sfp;
  SeqMgrFeatContext fcontext;
  ProtRefPtr        prp;
  AlphaProtPtr      app;
  
  if (bsp == NULL || userdata == NULL || ! ISA_aa (bsp->mol)) return;
  pList = (ValNodePtr PNTR) userdata;
  app = (AlphaProtPtr) MemNew (sizeof (AlphaProtData));
  if (app == NULL) return;
  app->bsp = bsp;
  app->prot_name = NULL;
  
  sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_PROT, 0, &fcontext);
  if (sfp != NULL && sfp->data.value.ptrvalue != NULL) 
  {
    prp = (ProtRefPtr) sfp->data.value.ptrvalue;
    if (prp->name != NULL)
    {
      app->prot_name = StringSave (prp->name->data.ptrvalue);
    }
    else
    {
      app->prot_name = StringSave (fcontext.label);
    }
  }
  ValNodeAddPointer (pList, 0, app);
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:30,代码来源:vsmfile.c

示例4: DustForGraph

extern FloatHiPtr DustForGraph (DustRegionPtr drp, Int4 length,
                                Int4 start, Int4 stop)
{
    DustRegionPtr drphead;
    FloatHiPtr    fhi, fhead;
    Int4          i;

    if (drp == NULL)
        return NULL;
    if (stop > length)
        return NULL;


    drphead = drp;
    if ((fhead = (FloatHiPtr) MemNew ((size_t)((sizeof(FloatHi))*length)))
            == NULL)
        return NULL;

    while (drp != NULL)
    {
        fhi = fhead;
        if (drp->from >= start && drp->from < length && drp->to < length)
        {
            fhi += drp->from;
            for (i = drp->from; i <= drp->to; i++)
            {
                *fhi = drp->percent;
                fhi++;
            }
        }
        drp = drp->next;
    }
    return fhead;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:34,代码来源:urkdust.c

示例5: SLRI_SSPush

/* Pushes a StringStack item onto StringStack */
Int4 
SLRI_SSPush(SLRI_SStackPtr ssp, CharPtr string) 
{
  SLRI_SStackItemPtr newItem = NULL;

  if (ssp == NULL) {
    ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPush: stack pointer is NULL");
    return(-1);
  }

  newItem = MemNew(sizeof(SLRI_SStackItem));

  newItem->string = string;
  newItem->prev = ssp->top;
  newItem->next = NULL; 

  if (ssp->top != NULL) {
    ssp->top->next = newItem;
  }

  ssp->top = newItem;
  ssp->totalStackSize += StringLen(newItem->string);
  ssp->totalNumItems++;

  /* If first item, set bottom pointer to top */
  if (ssp->bottom == NULL) {
    ssp->bottom = ssp->top;
  }

  return(0);
}
开发者ID:iandonaldson,项目名称:slri,代码行数:32,代码来源:slri_sstack.c

示例6: PngDecodeImage

bool PngDecodeImage(PngT *png, PixBufT *pixbuf) {
  if (png->ihdr.interlace_method != 0) {
    LOG("Interlaced PNG not supported.");
  } else if (png->ihdr.bit_depth != 8) {
    LOG("Non 8-bit components not supported.");
  } else {
    uint32_t pixelWidth = GetPixelWidth(png);
    uint32_t length = png->ihdr.width * png->ihdr.height * pixelWidth;
    uint32_t dstLength = length + png->ihdr.height;
    uint8_t *encoded = MemNew(dstLength);

    MergeIDATs(png);

    LOG("Uncompressing the image.");

    Inflate(png->idat.data + 2, encoded);

    LOG("Decoding pixels.");

    ReconstructImage(pixbuf->data, encoded,
                     png->ihdr.width, png->ihdr.height, pixelWidth);

    MemUnref(encoded);

    return true;
  }

  return false;
}
开发者ID:cahirwpz,项目名称:demoscene,代码行数:29,代码来源:png.c

示例7: MergeIDATs

/* Collapse multiple IDAT chunks into single one. */
static void MergeIDATs(PngT *png) {
  if (png->idat.next) {
    uint32_t length, i;
    uint8_t *data;
    IdatT *idat;

    for (idat = &png->idat, length = 0; idat; idat = idat->next)
      length += idat->length;

    LOG("Merged chunk length: %d.", length);

    data = MemNew(length);

    for (idat = &png->idat, i = 0; idat;) {
      IdatT *next = idat->next;

      MemCopy(data + i, idat->data, idat->length);
      i += idat->length;

      MemUnref(idat->data);
      if (idat != &png->idat)
        MemUnref(idat);

      idat = next;
    }

    png->idat.data = data;
    png->idat.length = length;
    png->idat.next = NULL;
  }
}
开发者ID:cahirwpz,项目名称:demoscene,代码行数:32,代码来源:png.c

示例8: Nlm_MonitorIntNewEx

NLM_EXTERN MonitorPtr LIBCALL Nlm_MonitorIntNewEx (Nlm_CharPtr title, Nlm_Int4 n1, Nlm_Int4 n2, Nlm_Boolean hasCancelBtn)
{
	AppMsgInfo *info = GetAppMsgInfo();
	Monitor *pMon = (Monitor*) MemNew(sizeof(Monitor));

	if (pMon != NULL)
	{
		MON_SET_MAGIC(pMon);
		pMon->type = MonType_Int;
		pMon->strTitle = title ? StrSave(title) : 0;
		pMon->num1 = n1;
		pMon->num2 = n2;
		pMon->cancel = FALSE;
		pMon->hasCancelBtn = (int) hasCancelBtn;
		if (!(*info->hookMonitor)(pMon,MonCode_Create))
		{
		    MonitorFree(pMon);
		    /* only post an information message here; it is expected
		    	that the hook function would report the real reason
		    	that the monitor creation failed. */
			ErrPostEx(SEV_INFO,0,0,"Unable to create monitor");
			return NULL;
		}
	}
	return pMon;
}
开发者ID:fbtestrepo,项目名称:hw,代码行数:26,代码来源:ncbimsg.c

示例9: SetUp

static XOSPtr SetUp (void)
{
  static GatherScope  gs;
  GatherScopePtr      gsp;
  XOSPtr              xosp;

  gsp = &gs;
  MemSet ((Pointer) gsp, 0, sizeof (GatherScope));
  MemSet ((Pointer) gsp->ignore, (int) (TRUE),
          (size_t) (OBJ_MAX * sizeof (Boolean)));
  gsp->ignore[OBJ_BIOSEQ] = FALSE;

  xosp = MemNew (sizeof (XOS));

  xosp->flagParamWindow = FALSE;
  xosp->gi = 0;
  xosp->filename = NULL;
  xosp->gsp = gsp;
  xosp->sep = NULL;
  xosp->bsp = NULL;

  xosp->pccp = PccDatNew ();

  return xosp;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:25,代码来源:ccpv.c

示例10: SetUp

static XOSPtr SetUp (void)
{
  static GatherScope  gs;
  GatherScopePtr      gsp;
  XOSPtr              xosp;

  gsp = &gs;
  MemSet ((Pointer) gsp, 0, sizeof (GatherScope));
  MemSet ((Pointer) gsp->ignore, (int) (TRUE),
          (size_t) (OBJ_MAX * sizeof (Boolean)));
  gsp->ignore[OBJ_BIOSEQ] = FALSE;

  xosp = MemNew (sizeof (XOS));

  xosp->flagParamWindow = FALSE;
  xosp->gi = 0;
  xosp->filename = NULL;
  xosp->gsp = gsp;
  xosp->sep = NULL;
  xosp->bsp = NULL;
  xosp->xdeltamin = 1;
  xosp->xdeltamax = 64;
  xosp->xdeltaval = 20;
  xosp->ydeltamin = 1;
  xosp->ydeltamax = 64;
  xosp->ydeltaval = 20;
  xosp->treestyle = 0;

  return xosp;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:30,代码来源:cnsrtv.c

示例11: GetGraphsProc

static Boolean GetGraphsProc (GatherObjectPtr gop)

{
  GphGetPtr    ggp;
  GphItemPtr   gip;
  SeqGraphPtr  sgp;

  if (gop == NULL || gop->itemtype != OBJ_SEQGRAPH) return TRUE;
  ggp = (GphGetPtr) gop->userdata;
  sgp = (SeqGraphPtr) gop->dataptr;
  if (ggp == NULL || sgp == NULL) return TRUE;
  /* only phrap or gap4 currently allowed */
  if (StringICmp (sgp->title, "Phrap Quality") == 0 ||
      StringICmp (sgp->title, "Gap4") == 0) {
    /* data type must be bytes */
    if (sgp->flags[2] == 3) {
      if (SeqIdForSameBioseq (SeqLocId (sgp->loc), SeqLocId (ggp->slp))) {
        gip = (GphItemPtr) MemNew (sizeof (GphItem));
        if (gip == NULL) return TRUE;
        gip->sgp = sgp;
        gip->left = GetOffsetInBioseq (sgp->loc, ggp->bsp, SEQLOC_LEFT_END);
        gip->right = GetOffsetInBioseq (sgp->loc, ggp->bsp, SEQLOC_RIGHT_END);
        ValNodeAddPointer (&(ggp->vnp), 0, (Pointer) gip);
      }
    }
  }
  return TRUE;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:28,代码来源:idcleanscan.c

示例12: tax_addNameClass

Boolean tax_addNameClass(Int4 class_cde, CharPtr class_txt, Int4 priority)
{
    Int2 i;

    if(name_class == NULL) {
	name_class= MemNew(sizeof(TaxNameClass)*class_alloced);
	if(name_class == NULL) return FALSE;
	
	for(i= 0; i < class_alloced; i++) {
	    name_class[i].priority= 1000;
	    name_class[i].class_txt[0]= name_class[i].class_txt[33]= '\0';	    
	}
    }
    
    if(class_cde < 0) return FALSE;

    if(class_cde >= class_alloced) {
	TaxNameClassPtr tmp= MemMore(name_class, sizeof(TaxNameClass)*(class_cde + 8));

	if(tmp == NULL) return FALSE;
	
	name_class= tmp;
	for(i= class_alloced; i < class_cde + 8; i++) {
	    name_class[i].priority= 1000;
	    name_class[i].class_txt[0]= name_class[i].class_txt[33]= '\0';	    
	}
	class_alloced= class_cde + 8;
    }

    name_class[class_cde].priority= priority;
    StringNCpy(name_class[class_cde].class_txt, class_txt, 33);

    return TRUE;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:34,代码来源:taxcs.c

示例13: tax_addRank

Boolean tax_addRank(Int2 rank_id, CharPtr rank_txt)
{
    Int2 i;

    rank_id+= d_rank;

    if(tax_rank == NULL) {
	tax_rank= MemNew(sizeof(TaxRank)*rank_alloced);
	if(tax_rank == NULL) return FALSE;
	
	for(i= 0; i < rank_alloced; i++) {
	    tax_rank[i].rank_txt[0]= tax_rank[i].rank_txt[63]= '\0';	    
	}
    }
    
    if(rank_id < 0) return FALSE;

    if(rank_id >= rank_alloced) {
	TaxRankPtr tmp= MemMore(tax_rank, sizeof(TaxRank)*(rank_id + 8));

	if(tmp == NULL) return FALSE;
	
	tax_rank= tmp;
	for(i= rank_alloced; i < rank_id + 8; i++) {
	    tax_rank[i].rank_txt[0]= tax_rank[i].rank_txt[63]= '\0';	    
	}
	rank_alloced= rank_id + 8;
    }

    StringNCpy(tax_rank[rank_id].rank_txt, rank_txt, 63);

    return TRUE;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:33,代码来源:taxcs.c

示例14: SeqEntryToFeat

static void SeqEntryToFeat (SeqEntryPtr sep, FILE *fp)

{
  AsnExpOptPtr  aeop;
  AsnIoPtr      aip;
  ExpStructPtr  esp;

  if (sep != NULL && fp != NULL) {
    esp = MemNew (sizeof (ExpStruct));
    if (esp != NULL) {
      aip = AsnIoNullOpen ();
      if (aip != NULL) {
        esp->fp = fp;
        esp->aip = AsnIoNew (ASNIO_TEXT_OUT, fp, NULL, NULL, NULL);
        esp->is_na = is_na;
        esp->feat = 3;  /* look for CdRegion SeqFeat */
        aeop = AsnExpOptNew (aip, "Seq-feat", (Pointer) esp, GetSeqFeat);
        if (aeop != NULL) {
          SeqEntryAsnWrite (sep, aip, NULL);
          fflush (fp);
          AsnExpOptFree (aip, aeop);
        }
        AsnIoClose (aip);
      }
      MemFree (esp);
    }
  }
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:28,代码来源:cdscan.c

示例15: FileListNew

/*****************************************************************************
*
*   Add a new file list element
*
*****************************************************************************/
static FileListPtr FileListNew (FileListPtr flp, Int2 cdnum,
                                CharPtr fdir, CharPtr fname)

{
  FileListPtr  newnode;

  newnode = (FileListPtr) MemNew (sizeof (FileList));
  if (newnode != NULL) {
    if (flp != NULL) {
      while (flp->next != NULL && flp->next->cdnum <= cdnum) {
        flp = flp->next;
      }
      newnode->next = flp->next;
      flp->next = newnode;
    }
    newnode->cdnum = cdnum;
    if (fdir != NULL && *fdir != '\0') {
      newnode->fdir = StringSave (fdir);
    }
    if (fname != NULL && *fname != '\0') {
      newnode->fname = StringSave (fname);
    }
  }
  return newnode;
}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:30,代码来源:cdscan.c


注:本文中的MemNew函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。