本文整理汇总了C++中New函数的典型用法代码示例。如果您正苦于以下问题:C++ New函数的具体用法?C++ New怎么用?C++ New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}