本文整理汇总了C++中New函数的典型用法代码示例。如果您正苦于以下问题:C++ New函数的具体用法?C++ New怎么用?C++ New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fl_file_chooser
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();
}
}
开发者ID:foobarz,项目名称:CLUCalcLinux,代码行数:38,代码来源:FLTKEditor.cpp
示例2: lock
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;
}
开发者ID:Web5design,项目名称:mozilla-central,代码行数:38,代码来源:SurfaceStream.cpp
示例3: ConnectTerm
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);
}
开发者ID:authorNari,项目名称:panda,代码行数:23,代码来源:termthread.c
示例4: PROFILER_LABEL
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;
}
开发者ID:PatMart,项目名称:gecko-dev,代码行数:23,代码来源:SurfaceStream.cpp
示例5: New
/* 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;
}
开发者ID:jmliu88,项目名称:leicester_cough_monitor_imitation,代码行数:24,代码来源:HCompV.c
示例6: store_alist_dir
/*
* 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);
}
开发者ID:s-seitz,项目名称:bareos,代码行数:29,代码来源:parse_conf.c
示例7: ShowStartupWizard
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);
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:23,代码来源:afswiz.cpp
示例8: void
/* 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;
}
开发者ID:botonchou,项目名称:AlgoFinal,代码行数:24,代码来源:HGraf_WIN32.c
示例9: Audio_mixer
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);
}
}
开发者ID:Blaizer,项目名称:Neverhood,代码行数:23,代码来源:Audio.c
示例10: AddArcTrans
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;
}
开发者ID:lovecpp2014,项目名称:htk-kenlm,代码行数:23,代码来源:HArc.c
示例11: Exercise4
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);
}
开发者ID:bennybroseph,项目名称:Homework,代码行数:23,代码来源:Source.cpp
示例12: vMessage
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);
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:37,代码来源:tal_dialog.cpp
示例13: main
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);
}
开发者ID:prelegalwonder,项目名称:bacula,代码行数:37,代码来源:main.c
示例14: Server_Hosts_OnAddEntry
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);
}
开发者ID:bagdxk,项目名称:openafs,代码行数:37,代码来源:svr_hosts.cpp
示例15: New
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;
}
开发者ID:geekt,项目名称:quazaa,代码行数:37,代码来源:g2packet.cpp
示例16: while
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++;
}
}
开发者ID:jovazxc,项目名称:samp,代码行数:39,代码来源:vehiclepool.cpp
示例17: poly_mod_pow
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;
}
开发者ID:Akron,项目名称:Math-Prime-Util,代码行数:24,代码来源:aks.c
示例18: test_three
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) ;
}
开发者ID:lirui79,项目名称:CProject,代码行数:36,代码来源:main.c
示例19: CloneStream
/* 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;
}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:25,代码来源:HUtil.c
示例20: SortArcs
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 );
}
开发者ID:lovecpp2014,项目名称:htk-kenlm,代码行数:36,代码来源:HArc.c
注:本文中的New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论