コード例 #1
0
ファイル: FLTKEditor.cpp プロジェクト: foobarz/CLUCalcLinux
void CFLTKEditor::Load()
{
/*
	if (!CheckSave())
		return;
*/

	char pcFilename[512];

	pcFilename[0] = 0;
	Fl_File_Chooser::sort = fl_casenumericsort;
	char *pcNewFile = fl_file_chooser(m_sFileChooserLoadTitle.c_str(), 
							m_sFileChooserPattern.c_str(), pcFilename);

	if (pcNewFile != NULL) 
	{
		int i, iCount = m_mEditorData.Count();
		// Check whether file has already been loaded
		for (i = 0; i < iCount; i++)
		{
			if (pcNewFile == m_mEditorData[i].m_sFilename)
			{
				// if file is found, select it
				SetCurEditor(i);
				break;
			}
		}

		// if file has not been loaded then do load it.
		if (i == iCount)
		{
			New();
			LoadFile(pcNewFile);
		}

		UpdateFileList();
	}
}
コード例 #2
0
SharedSurface*
SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory,
                                         const gfxIntSize& size)
{
    MutexAutoLock lock(mMutex);
    if (mConsumer) {
        Recycle(factory, mConsumer);
    }

    if (mProducer) {
        // Fence now, before we start (maybe) juggling Prod around.
        mProducer->Fence();

        // Size mismatch means we need to squirrel the current Prod
        // into Cons, and leave Prod empty, so it gets a new surface below.
        bool needsNewBuffer = mProducer->Size() != size;

        // Even if we're the right size, if the type has changed, and we don't
        // need to preserve, we should switch out for (presumedly) better perf.
        if (mProducer->Type() != factory->Type() &&
            !factory->Caps().preserve)
        {
            needsNewBuffer = true;
        }

        if (needsNewBuffer) {
            Move(mProducer, mConsumer);
        }
    }

    // The old Prod (if there every was one) was invalid,
    // so we need a new one.
    if (!mProducer) {
        New(factory, size, mProducer);
    }

    return mProducer;
}
コード例 #3
0
ファイル: termthread.c プロジェクト: authorNari/panda
extern	int
ConnectTerm(
	int		_fhTerm)
{
	int				fhTerm;
	pthread_t		thr;
	pthread_attr_t	attr;
	TermNode		*term;

ENTER_FUNC;
	pthread_attr_init(&attr);
	pthread_attr_setstacksize(&attr,256*1024);
	if ((fhTerm = accept(_fhTerm,0,0)) < 0) {
		Error("accept(2) failure:%s",strerror(errno));
	}
	term = New(TermNode);
	term->que = NewQueue();
	term->fp = SocketToNet(fhTerm);
	pthread_create(&thr,&attr,(void *(*)(void *))TermThread,(void *)term);
	pthread_detach(thr);
LEAVE_FUNC;
	return	(fhTerm); 
}
コード例 #4
0
ファイル: SurfaceStream.cpp プロジェクト: PatMart/gecko-dev
SharedSurface*
SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory,
                                         const gfx::IntSize& size)
{
    PROFILER_LABEL("SurfaceStream_TripleBuffer", "SwapProducer");

    MonitorAutoLock lock(mMonitor);
    if (mProducer) {
        RecycleScraps(factory);

        if (mStaging)
            Scrap(mStaging);

        MOZ_ASSERT(!mStaging);
        Move(mProducer, mStaging);
        mStaging->Fence();
    }

    MOZ_ASSERT(!mProducer);
    New(factory, size, mProducer);

    return mProducer;
}
コード例 #5
0
/* Append speaker accumulate structure list */
SpkrAccListItem *AppendSpkrAccList(SpkrAccListItem *sal, SpkrAcc *sa)
{
   SpkrAccListItem *temp;
   int i;

   temp = New(&gstack,sizeof(SpkrAccListItem));
   temp->sa = InitSpkrAcc();
   for (i=1;i<=vSize;i++){
      temp->sa->meanSum[i] = sa->meanSum[i];
      temp->sa->squareSum[i] = sa->squareSum[i];
   }
   temp->sa->NumFrame = sa->NumFrame;
   strcpy(temp->sa->SpkrName,sa->SpkrName);
   temp->nextSpkr = sal;
   sal = temp;
  
   if (trace&T_CMV){
      fprintf(stdout,"Creating entry for speaker %s ......\n",sa->SpkrName);
      fflush(stdout);
   }

   return sal;
}
コード例 #6
0
ファイル: parse_conf.c プロジェクト: s-seitz/bareos
/*
 * Store a directory name at specified address in an alist.
 * Note, we do shell expansion except if the string begins
 * with a vertical bar (i.e. it will likely be passed to the
 * shell later).
 */
void store_alist_dir(LEX *lc, RES_ITEM *item, int index, int pass)
{
   alist *list;

   if (pass == 2) {
      if (*(item->value) == NULL) {
         list = New(alist(10, owned_by_alist));
      } else {
         list = (alist *)(*(item->value));
      }

      lex_get_token(lc, T_STRING);   /* scan next item */
      Dmsg4(900, "Append %s to alist %p size=%d %s\n",
            lc->str, list, list->size(), item->name);
      if (lc->str[0] != '|') {
         do_shell_expansion(lc->str, sizeof(lc->str));
      }
      list->append(bstrdup(lc->str));
      *(item->value) = (char *)list;
   }
   scan_to_eol(lc);
   set_bit(index, res_all.hdr.item_present);
}
コード例 #7
0
ファイル: afswiz.cpp プロジェクト: maxendpoint/openafs_cvs
void ShowStartupWizard (void)
{
   if (g.pWizard != NULL) // Already showing the wizard? Stop here.
      return;

   memset (&l, 0x00, sizeof(l));

   g.pWizard = New(WIZARD);

   g.pWizard->SetDialogTemplate (IDD_WIZARD, IDC_LHS, IDC_RHS, IDBACK, IDNEXT);
   g.pWizard->SetGraphic (IDB_WIZ16, IDB_WIZ256);
   g.pWizard->SetStates (aStates, cStates);
   g.pWizard->SetState (STEP_START);

   g.pWizard->Show();

   Delete(g.pWizard);
   g.pWizard = NULL;

   Main_RepopulateTabs (TRUE);

   FreeDriveMapList (&l.List);
}
コード例 #8
0
ファイル: HGraf_WIN32.c プロジェクト: botonchou/AlgoFinal
/* EXPORT->CreateHButton: create a button object with the specified parameters */
HButton *CreateHButton(HButton *btnlst, ButtonId btnid, int x, int y, int w, 
                       int h, char *str, HColour fg, HColour bg, void (*action)(void))
{
   HButton *btn, *btnptr;
   
   btn = New(&btnHeap, sizeof(HButton));
   /* initialise the fields of the structure */
   btn->id = btnid;
   btn->x = x;   btn->y = y;   btn->w = w;   btn->h = h;
   btn->str = str;
   btn->fg = fg;   btn->bg = bg;
   btn->lit = FALSE; btn->active = TRUE; btn->toggle = FALSE;
   btn->next = NULL;
   /* append it to the end of the list if the list already exists */
   if (btnlst!=NULL){
      btnptr = btnlst;
      while (btnptr->next != NULL) btnptr = btnptr->next;
      btnptr->next = btn;
   }
   btn->action = action;
   /* return ptr to the newly created button */
   return btn;
}
コード例 #9
0
ファイル: Audio.c プロジェクト: Blaizer/Neverhood
static void Audio_mixer (void* udata, Uint8* buf, int size)
{
	(void)udata;
	Zero(buf, size, Uint8);
	if (!_audio.buf) {
		_audio.buf = New(size, Uint8);
		_audio.spec.samples = size;
	}

	MusicResource* music = _audio.music;
	SmackerResource* smacker = SDL_AtomicGetPtr((void**)&_audio.smacker);

	if (music) {
		MusicResource_play(music, _audio.buf, size);

		SDL_MixAudioFormat(buf, _audio.buf, AUDIO_S16LSB, size, _audio.volume);
	}
	if (smacker) {
		SmackerResource_play_audio(smacker, _audio.buf, size);

		SDL_MixAudioFormat(buf, _audio.buf, AUDIO_S16LSB, size, _audio.volume);
	}
}
コード例 #10
0
ファイル: HArc.c プロジェクト: lovecpp2014/htk-kenlm
void AddArcTrans(MemHeap *mem,  HArc *start, HArc *end, float lmlike){
   /*Adds a transition with probability "lmlike" scaled by "lmScale".  The reason those two are given separately
     (instead of their product) is that it makes a difference when two transitions are added. */

   ArcTrans *at;

   at = (ArcTrans*)New(mem, sizeof(ArcTrans));
   at->start = start;
   at->end = end;
   at->lmlike = lmlike;
   if (isnan(lmlike)) HError(1, "lmlike isnan..");
   /*insert it into the ll attached to start->follTrans.*/
   at->start_foll = start->follTrans;
   if(start->follTrans) start->follTrans->start_prec = at;
   start->follTrans=at;
   at->start_prec = NULL;
    
   /*insert it into the ll attached to end->precTrans.*/
   at->end_foll = end->precTrans;
   if(end->precTrans) end->precTrans->end_prec = at;
   end->precTrans=at;
   at->end_prec = NULL;
}
コード例 #11
0
ファイル: Source.cpp プロジェクト: bennybroseph/Homework
void Exercise4()
{
	Player_Struct Players[5];
	
	int i;
	for (i = 0; i < 5; i++)
	{
		Ask(Players[i]);
		if (i < 4)
			std::cout << "-----------------------" << std::endl;
	}
	for (i = 0; i < 5; i++)
	{
		Tell(Players[i]);

		if (i < 4)
			std::cout << std::endl << "-----------------------";
	}

	End();
	New("5");
	Exercise5(Players);
}
コード例 #12
0
int cdecl vMessage (UINT type, LONG title, LONG text, LPCTSTR fmt, va_list arg)
{
   LPMESSAGE_PARAMS pmp = New(MESSAGE_PARAMS);

   pmp->dwType = type;

   if ((pmp->pszTitle = FormatString (title, fmt, arg)) == NULL)
      {
      Delete(pmp);
      return IDCANCEL;
      }

   if ((pmp->pszText = vFormatString (text, fmt, arg)) == NULL)
      {
      FreeString (pmp->pszTitle);
      Delete(pmp);
      return IDCANCEL;
      }

   if (!( pmp->dwType & 0xF0 )) // no icon requested?  pick one.
      {
      pmp->dwType |= ((pmp->dwType & 0x0F) ? MB_ICONQUESTION : MB_ICONASTERISK);
      }

   if (pmp->dwType & MB_MODELESS)
      {
      pmp->dwType &= ~MB_MODELESS;

      HANDLE hThread;
      if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)Message_ThreadProc, pmp, 0, NULL)) != NULL)
         SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL);

      return -1; // threaded--who knows what button was hit.
      }

   return Message_ThreadProc (pmp);
}
コード例 #13
0
ファイル: main.c プロジェクト: prelegalwonder/bacula
int main(int argc, char *argv[])
{
   char plugin_dir[1000];
   bpContext ctx;
   bEvent event;
   Plugin *plugin;
    
   b_plugin_list = New(alist(10, not_owned_by_alist));

   ctx.bContext = NULL;
   ctx.pContext = NULL;
   getcwd(plugin_dir, sizeof(plugin_dir)-1);

   load_plugins((void *)&bfuncs, plugin_dir, plugin_type);

   foreach_alist(plugin, b_plugin_list) {
      printf("bacula: plugin_size=%d plugin_version=%d\n", 
              pref(plugin)->size, pref(plugin)->interface);
      printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n",
         pref(plugin)->plugin_license, pref(plugin)->plugin_author, 
         pref(plugin)->plugin_date, pref(plugin)->plugin_version, 
         pref(plugin)->plugin_description);

      /* Start a new instance of the plugin */
      pref(plugin)->newPlugin(&ctx);
      event.eventType = bEventNewVolume;   
      pref(plugin)->handlePluginEvent(&ctx, &event);
      /* Free the plugin instance */
      pref(plugin)->freePlugin(&ctx);

      /* Start a new instance of the plugin */
      pref(plugin)->newPlugin(&ctx);
      event.eventType = bEventNewVolume;   
      pref(plugin)->handlePluginEvent(&ctx, &event);
      /* Free the plugin instance */
      pref(plugin)->freePlugin(&ctx);
   }
コード例 #14
0
ファイル: svr_hosts.cpp プロジェクト: bagdxk/openafs
void Server_Hosts_OnAddEntry (HWND hDlg, LPSVR_HOSTS_PARAMS lpp)
{
   LPSVR_ADDHOST_PARAMS pAdd = New (SVR_ADDHOST_PARAMS);
   memset (pAdd, 0x00, sizeof(pAdd));
   pAdd->lpiServer = lpp->lpiServer;

   if (ModalDialogParam (IDD_SVR_ADDHOST, hDlg, (DLGPROC)Server_AddHost_DlgProc, (LPARAM)pAdd) == IDOK)
      {
      size_t iEntry;
      for (iEntry = 0; iEntry < lpp->lpList->cEntries; ++iEntry)
         {
         LPHOSTLISTENTRY pEntry = &lpp->lpList->aEntries[ iEntry ];
         if (pEntry->szHost[0] == TEXT('\0'))
            continue;
         if (!lstrcmpi (pEntry->szHost, pAdd->szHost))
            break;
         }

      if (iEntry >= lpp->lpList->cEntries)
         {
         iEntry = AfsClass_HostList_AddEntry (lpp->lpList, pAdd->szHost);
         }

      HWND hList = GetDlgItem (hDlg, IDC_HOST_LIST);
      FL_StartChange (hList, FALSE);

      HLISTITEM hItem;
      if ((hItem = FastList_FindItem (hList, (LPARAM)iEntry)) == NULL)
         {
         hItem = FL_AddItem (hList, 1, (LPARAM)iEntry, 0, pAdd->szHost);
         }

      FL_EndChange (hList, (LPARAM)hItem);
      }

   Delete (pAdd);
}
コード例 #15
0
ファイル: g2packet.cpp プロジェクト: geekt/quazaa
G2Packet* G2Packet::New(char* pSource)
{
	G2Packet* pPacket = New();

	char nInput		= *pSource++;

	char nLenLen	= ( nInput & 0xC0 ) >> 6;
	char nTypeLen	= ( nInput & 0x38 ) >> 3;
	char nFlags	= ( nInput & 0x07 );

	pPacket->m_bCompound	= ( nFlags & G2_FLAG_COMPOUND ) ? true : false;
	bool	bBigEndian	= ( nFlags & G2_FLAG_BIG_ENDIAN ) ? true : false;

	quint32 nLength = 0;

	if ( bBigEndian )
	{
		throw packet_error();
	}
	else
	{
		char* pLenOut = (char*)&nLength;
		while ( nLenLen-- ) *pLenOut++ = *pSource++;
	}

	nTypeLen++;
	char* pszType = pPacket->m_sType;
	for ( ; nTypeLen-- ;  )
	{
		*pszType++ = *pSource++;
	}
	*pszType++ = 0;

	pPacket->Write( pSource, nLength );

	return pPacket;
}
コード例 #16
0
ファイル: vehiclepool.cpp プロジェクト: jovazxc/samp
void CVehiclePool::ProcessWaitingList()
{
	int x=0;
	while(x!=MAX_VEHICLE_WAITING_SLOTS) {
		if(m_bWaitingSlotState[x] && pGame->IsModelLoaded(m_NewVehicleWaiting[x].iVehicleType))
		{		
			New(&m_NewVehicleWaiting[x]);
    
			// TRAIN STUFF
			if(m_NewVehicleWaiting[x].iVehicleType == TRAIN_FREIGHT_LOCO) {
				m_NewVehicleWaiting[x].iVehicleType = TRAIN_FREIGHT;

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);	
			}

			if(m_NewVehicleWaiting[x].iVehicleType == TRAIN_PASSENGER_LOCO) {
				m_NewVehicleWaiting[x].iVehicleType = TRAIN_PASSENGER;

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);

				m_NewVehicleWaiting[x].VehicleId++;
				New(&m_NewVehicleWaiting[x]);	
			}
			m_bWaitingSlotState[x] = FALSE;
		}
		x++;
	}
}
コード例 #17
0
ファイル: aks.c プロジェクト: Akron/Math-Prime-Util
static UV* poly_mod_pow(UV* pn, UV power, UV r, UV mod)
{
  UV* res;
  UV* temp;
  int use_sqr = (mod > sqrt(UV_MAX/r)) ? 0 : 1;

  Newz(0, res, r, UV);
  New(0, temp, r, UV);
  if ( (res == 0) || (temp == 0) )
    croak("Couldn't allocate space for polynomial of degree %lu\n", (unsigned long) r);

  res[0] = 1;

  while (power) {
    if (power & 1)  poly_mod_mul(res, pn, temp, r, mod);
    power >>= 1;
    if (power) {
      if (use_sqr)  poly_mod_sqr(pn, temp, r, mod);
      else          poly_mod_mul(pn, pn, temp, r, mod);
    }
  }
  Safefree(temp);
  return res;
}
コード例 #18
0
ファイル: main.c プロジェクト: lirui79/CProject
void test_three()
{
	Circle   *circle ;
	Point    *point ;
	Shape    *shape ;
	IMethod  *ptr ;
	double area = 0.0 ;
	circle = New(Circle) ;

	circle->Set(circle , 10.0 , 20.0) ;
	circle->Move(circle , 100.0 , 300.0) ;

	circle->Position(circle) ;

	circle->SetRadius(circle , 30.0) ;
	area = circle->Area(circle) ;

	circle->SetCircle(circle , 1.0 , 2.0 , 3.0) ;

	shape = (Shape*)circle ;
	shape->Position(shape) ;
	area = shape->Area(shape) ;

	point = (Point*)circle ;
	point->Move(point , 1000.0 , 2000.0) ;
	point->Position(point) ;

	circle->AddRadius(circle , 50.0) ;
	area = point->Area(point) ;

	ptr = (IMethod*)circle ;
//	area = ptr->Area() ;
    ptr->GetClassName() ;
	Delete(ptr) ;

}
コード例 #19
0
ファイル: HUtil.c プロジェクト: deardaniel/PizzaTest
/* CloneStream: return a clone of given stream */
MixtureVector CloneStream(HMMSet *hset, StreamElem *ste, Boolean sharing)
{
   int m,M;
   MixtureElem *sme,*tme;
   MixtureVector mv;

   M = ste->nMix;
   if (hset->hsKind == PLAINHS || hset->hsKind == SHAREDHS){
      tme = (MixtureElem *)New(hset->hmem,M*sizeof(MixtureElem));
      mv.cpdf = tme-1; sme = ste->spdf.cpdf + 1;
      for (m=1; m<=M; m++,sme++,tme++){
         tme->weight = sme->weight;
         tme->mpdf =
            (tme->weight>MINMIX)?CloneMixPDF(hset,sme->mpdf,sharing):NULL;
      }
   } else if (hset->hsKind == TIEDHS) {
      mv.tpdf = CreateVector(hset->hmem,M);
      CopyVector(ste->spdf.tpdf,mv.tpdf);
   } else {
      mv.dpdf = CreateShortVec(hset->hmem,M);
      CopyShortVec(ste->spdf.dpdf,mv.dpdf);
   }
   return mv;
}
コード例 #20
0
ファイル: HArc.c プロジェクト: lovecpp2014/htk-kenlm
void SortArcs( ArcInfo *aInfo )
{
   int q;
   HArc   **arclist = (HArc**)New( &gstack , aInfo->nArcs * sizeof(HArc*) );
   HArc   *a , *prec = NULL ;  
   HArc   **al = arclist , **ale = arclist + aInfo->nArcs ;
   int   id = 1 ;

   for ( a = aInfo->start ; al != ale ; *(al++) = a , a = a->foll );

   qsort( arclist , aInfo->nArcs , sizeof(HArc*) , arc_compare ); 

   for ( al = arclist ; al != ale ; ++al )
      {
         (*al)->prec = prec ; prec = *al ; 
         (*al)->foll = *(al+1) ; 
         (*al)->id = id++ ;
      }

   /* prec should point to last arc */
   prec->foll   = NULL;
   aInfo->start = *arclist ;
   aInfo->end   = prec;
   /*
     for ( al = arclist ; al != ale ; ++al )
     {
     printf("%p ( prec %10p foll %10p ) %-5d %-12f %-12f \n",
     *al , (*al)->prec , (*al)->foll , (*al)->id , (*al)->t_end , (*al)->t_start );
     }
     printf("%p %p %p\n" , prec , aInfo->start , aInfo->end ); fflush(stdout);
   */
   q=0;
   for(a=aInfo->start;a;a=a->foll)
      a->id = ++q;
   Dispose( &gstack , arclist );
}
コード例 #21
0
ファイル: file.cpp プロジェクト: tianjigezhu/UI-Library
LPCTSTR ringFile::Titlename() const
{
	if(m_lpszTitlename == NULL)
		(LPTSTR)m_lpszTitlename = (LPTSTR)New(MAX_PATH);

	if(m_lpszTitlename && m_lpszTitlename[0] == '\0' && m_lpszFilename)
	{
		LPTSTR p = (LPTSTR)m_lpszFilename + strlen(m_lpszFilename) - 1;
		//LPTSTR v = p + 1;
		while(p != m_lpszFilename)
		{
			if(*p == '.')
			{
				//顺便置一下扩展名
				(LPSTR)m_lpszExtname = p + 1;
				memcpy((LPSTR)m_lpszTitlename,m_lpszFilename,p - m_lpszFilename);
				return m_lpszTitlename;
			}
			p --;
		}
		strcpy((LPSTR)m_lpszTitlename,m_lpszFilename);
	}
	return (LPCTSTR)m_lpszTitlename;
}
コード例 #22
0
LAlign *LAlignFromModpath (DecoderInst *dec, MemHeap *heap,
                           ModendHyp *modpath, int wordStart, short *nLAlign)
{
   ModendHyp *m;
   LAlign *lalign;
   MLink ml;
   int n;
   int startFrame = 0;
   
   n = 0;
   for (m = modpath; m; m = m->prev)
      if (m->ln->type == LN_MODEL)
         ++n;
   
   lalign = New (heap, n * sizeof(LAlign));
   *nLAlign = n;
   
   for (m = modpath; m; m = m->prev) {
      if (m->ln->type == LN_MODEL) {
         startFrame = (m->prev ? m->prev->frame : wordStart);
         ml = FindMacroStruct (dec->hset, 'h', (Ptr) m->ln->data.hmm);
         if (!ml)
            HError (9999, "LAlignFromModpath: model not found!");

         assert (m->frame >= startFrame);
         --n;
         lalign[n].state = -1;
         lalign[n].like = 0.0;
         lalign[n].dur = (m->frame - startFrame) * dec->frameDur;
         lalign[n].label = ml->id;
      }
   }
   assert (n == 0);

   return (lalign);
}
コード例 #23
0
static matrix_t constructMat(unsigned int cols, unsigned int rows)
{
  unsigned int i;
  matrix_t m;
  size_t nbytes = matBytes(cols);
  unsigned int mat2offset = rightMatrixOffset(cols);

  /* printf("construct mat %u %u (%lu bytes)\n", cols, rows, rows*sizeof(row) + rows*(2*nbytes)); */
  /* If cols > rows, we write off the array */
  if (cols < rows) croak("SIMPQS:  cols %u > rows %u\n", cols, rows);
  New(0, m, rows, row_t);
  if (m == 0) croak("SIMPQS: Unable to allocate memory for matrix!\n");

  for (i = 0; i < rows; i++) { /* two matrices, side by side */
    Newz(0, m[i], 2*nbytes, unsigned char);
    if (m[i] == 0) croak("SIMPQS: Unable to allocate memory for matrix!\n");
  }

  /* make second matrix identity, i.e. 1's along diagonal */
  for (i = 0; i < rows; i++)
    insertEntry(m, i, mat2offset + i);

  return m;
}
コード例 #24
0
inline void CStaticArray<Type>::Expand(INDEX iNewCount)
{
  ASSERT(this!=NULL && iNewCount>sa_Count);
  // if not already allocated
  if (sa_Count==0) {
    // just allocate
    New(iNewCount);
    return;
  // if already allocated
  } else {
    ASSERT(sa_Count!=0 && sa_Array!=NULL);
    // allocate new array with more space
    Type *ptNewArray = new Type[iNewCount+1]; //(+1 for cache-prefetch opt)
    // copy old objects
    for (INDEX iOld=0; iOld<sa_Count; iOld++) {
      ptNewArray[iOld] = sa_Array[iOld];
    }
    // free old array
    delete[] sa_Array;
    // remember the new array
    sa_Count = iNewCount;
    sa_Array = ptNewArray;
  }
}
コード例 #25
0
ファイル: addr_init_intel.c プロジェクト: berkus/nemesis
// glue function - converts Mem_Map to Mem_PMemDesc and forwards to FramesMod$New ctor.
FramesF_cl *InitPMem(FramesMod_cl *fmod, Mem_PMem allmem, Mem_Map memmap, 
		     RamTab_cl *rtab, addr_t free)
{
    Mem_PMemDesc used[32];
    FramesF_clp framesF;
    int i, j;

    TRC(eprintf("InitPMem: INTEL.\n"));

    /* Determine the used pmem from the mapping info */
    j = 0;
    for(i=0; memmap[i].nframes; i++) {
	used[i].start_addr  = memmap[i].paddr;
	used[i].nframes     = memmap[i].nframes;
	used[i].frame_width = memmap[i].frame_width; 
	used[i].attr      = 0;
    }

    /* now terminate the array */
    used[i].nframes = 0;

    framesF = FramesMod$New(fmod, allmem, used, rtab, free);
    return framesF;
}
コード例 #26
0
//
// Creates a copy of the specified access spec, and returns a copy.
//
Test_Spec* AccessSpecList::Copy( Test_Spec *source_spec )
{
	int copy_number;
	CString name;
	Test_Spec* spec;

	// Create a new spec and check the validity of source_spec.
	if ( !(spec = New()) || IndexByRef( source_spec ) == IOERROR )
		return NULL;

	// Copy the source spec into the newly created one.
	memcpy( spec, source_spec, sizeof Test_Spec );

	// Assign a unique name: Copy of 'name of source spec' ('unique copy number').
	name.Format( "Copy of %s", spec->name );
	copy_number = 1;
	do
	{
		sprintf( spec->name, "%s (%d)", name, copy_number++ );
	}
	while ( RefByName( spec->name ) != spec );

	return spec;
}
コード例 #27
0
void AddImage( char *name )
{
   PIMAGE_DISPLAY pdi;
	pdi = New( IMAGE_DISPLAY );

	pdi->Loaded = LoadImageFile( name );
	if( !pdi->Loaded )
	{
		Release( pdi );
      return;
	}
   pdi->display = OpenDisplaySizedAt( 0
												, pdi->Loaded->width, pdi->Loaded->height
												, g.x, g.y );
	SetRedrawHandler( pdi->display, DrawImage, (uintptr_t)pdi );
   DrawImage( (uintptr_t)pdi, pdi->display );
	SetKeyboardHandler( pdi->display, KeyHandler, 0 );
	g.x += 10;
   g.y += 10;
	if( ( pdi->next = g.images ) )
      pdi->next->me = &pdi->next;
	pdi->me = &g.images;
	g.images = pdi;
}
コード例 #28
0
  TaskResult Commit(Layer layerType){
    if (m_active){
      EndEntry();
    }
    if (m_newTextObject){
      m_command.Set(add_or_draw(m_textObject, layerType));
      return TaskResult::COMMIT_AND_CHANGE;
    }

    const utf8_string& newText(m_textObject->GetTextBuffer().get());
    std::deque<CommandPtr> cmds;
    while (m_states.CanUndo()){
      // Fixme: Dificult to understand (first undo just moves between lists)
      TextChange& change = m_states.UndoToRedo();
      change.Undo();
      cmds.emplace_back(std::make_unique<TextCommand>(change));
    }

    if (newText != m_oldText){
      // Fixme: Do all changes, also text edits, via TextChange instead
      cmds.push_back(text_entry_command(m_textObject,
        New(newText),
        Old(m_oldText)));
    }

    if (cmds.empty()){
      // No changes - create no command.
      return TaskResult::CHANGE;
    }
    else{
      m_command.Set(perhaps_bunch(CommandType::OBJECT,
        bunch_name("Modify Text"),
        std::move(cmds)));
      return TaskResult::COMMIT_AND_CHANGE;
    }
  }
コード例 #29
0
ファイル: pickuppool.cpp プロジェクト: LBRGeorge/jmnvc
BOOL CPickupPool::InitialiseFromConfig(CConfig *pConfig)
{
    int iPickupArrayCount;
    BYTE d=1;

    int iModelID;
    VECTOR vecPos;
    char * szConfigLine;

    iPickupArrayCount = pConfig->GetConfigArrayCount("PICKUP");
	iPickupArrayCount++;

    while((int)d < iPickupArrayCount) {

         szConfigLine = pConfig->GetConfigEntryAsString("PICKUP",d);

		 sscanf(szConfigLine,"%d%f%f%f%f%d%d",&iModelID,&vecPos.X,&vecPos.Y,&vecPos.Z);

         New(d,(BYTE)iModelID,&vecPos);
         d++;
    }

    return TRUE;
}
コード例 #30
0
ファイル: subset.cpp プロジェクト: maxendpoint/openafs_cvs
LPSUBSET Subsets_OnCheck (HWND hDlg, int iSel, LPSUBSET subOld)
{
   LPSUBSET sub = subOld;
   HWND hList = GetDlgItem (hDlg, IDC_SUBSET_LIST);

   if (!LB_GetCheck (hList, iSel))  // unchecked?
      {
      if (!sub)
         {
         sub = New (SUBSET);
         memset (sub, 0x00, sizeof(SUBSET));
         }
      }

   if (sub)
      {
      sub->fModified = TRUE;
      Subsets_GetSubsetFromDialog (hDlg, sub);
      Subsets_SetName (hDlg, sub);
      PropSheetChanged (hDlg);
      }

   return sub;
}