本文整理汇总了C++中GetMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMemory函数的具体用法?C++ GetMemory怎么用?C++ GetMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetMemory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
FILE* ON_Workspace::OpenFile( const wchar_t* sFileName, const wchar_t* sMode )
{
FILE* pFile = ON::OpenFile( sFileName, sMode );
if ( pFile )
{
struct ON_Workspace_FBLK* pFileBlk = (struct ON_Workspace_FBLK*)GetMemory( sizeof(*pFileBlk) );
pFileBlk->pNext = m_pFileBlk;
pFileBlk->pFile = pFile;
m_pFileBlk = pFileBlk;
}
return pFile;
}
示例2: GetProtocolFactory
//删除协议上下文
void IAppInterface::DeleteProtocolContext(ProtocolContext *context)
{
//释放protocol实例
IProtocolFactory *factory = GetProtocolFactory();
if(context->protocol != NULL)
factory->DeleteProtocol(context->protocol_type, context->protocol);
IMemory *memory = GetMemory();
assert(context!=NULL);
context->~ProtocolContext();
memory->Free((void*)context, sizeof(ProtocolContext));
}
示例3: GetMemory
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
node_t *AllocNode (void)
{
node_t *node;
node = GetMemory(sizeof(*node));
memset (node, 0, sizeof(*node));
if (numthreads == 1)
{
c_nodememory += MemorySize(node);
} //end if
return node;
} //end of the function AllocNode
示例4: GetMemoryDebug
void *GetClearedMemory(unsigned long size)
#endif //MEMDEBUG
{
void *ptr;
#ifdef MEMDEBUG
ptr = GetMemoryDebug(size, label, file, line);
#else
ptr = GetMemory(size);
#endif //MEMDEBUG
memset(ptr, 0, size);
return ptr;
}
示例5: l
void InternalAllocator::ReleaseAllMemory()
{
std::lock_guard<std::mutex> l(m_PagesMutex);
// walk all pages backwards and kill them
Page* next = m_Tail;
while(next) {
auto current = next;
next = current->GetPrevious();
current->~Page();
m_ExternalAllocator->Deallocate(current->GetMemory());
}
}
示例6: GetMemory
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
libvar_t *LibVarAlloc( char *var_name ) {
libvar_t *v;
v = (libvar_t *) GetMemory( sizeof( libvar_t ) + strlen( var_name ) + 1 );
memset( v, 0, sizeof( libvar_t ) );
v->name = (char *) v + sizeof( libvar_t );
strcpy( v->name, var_name );
//add the variable in the list
v->next = libvarlist;
libvarlist = v;
return v;
} //end of the function LibVarAlloc
示例7: InitUndo
/*
Alloc UNDO/REDO structures
*/
void InitUndo()
{
// Check MaxUndo global var.
if ( MaxUndo < 1 ) MaxUndo = 1;
// Allocates MaxUndo+1 entries
if ( UndoArray == NULL )
UndoArray = (UndoData *)GetMemory (MaxUndo * sizeof(UndoData));
NbUndo = 0;
NextUndo = -1;
}
示例8: GetLink
/**************************************************************
功能:从 src 中分析出网页链接,并加入到当前节点的子节点上
***************************************************************/
void GetLink(char * src)
{
char * pa, * pb, * pc;
char * myanchor = 0;
int len = 0;
pa = src;
do
{
if((pb = strstr(pa, "href='")))
{
pc = strchr(pb + 6, '\'');
len = strlen(pb + 6) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 6, len);
}
else if((pb = strstr(pa, "href=\"")))
{
pc = strchr(pb + 6, '"');
len = strlen(pb + 6) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 6, len);
}
else if((pb = strstr(pa, "href=")))
{
GetAfterPosWithSlash(pb + 5, &pc);
len = strlen(pb + 5) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 5, len);
}
else {goto __returnLink ;}
if(strlen(myanchor) > 0)
AddChildNode(NodeCurr, myanchor);
if(pc + 1)
pa = pc + 1;
}while(pa);
__returnLink:
return;
}
示例9: GetLink
/**************************************************************
功能:从 src 中分析出网页链接,并加入到当前节点的子节点上
***************************************************************/
void GetLink(char * src)
{
char * pa, * pb, * pc;
char * myanchor = 0;
int len = 0;
pa = src;
do {
if((pb = strstr(pa, "href='"))) {
pc = strchr(pb + 6, '\'');
len = strlen(pb + 6) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 6, len);
}
else if((pb = strstr(pa, "href=\""))) {
pc = strchr(pb + 6, '"');
len = strlen(pb + 6) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 6, len);
}
else if((pb = strstr(pa, "href="))) {
GetAfterPosWithSlash(pb + 5, &pc);
len = strlen(pb + 5) - strlen(pc);
GetMemory(&myanchor, len);
memcpy(myanchor, pb + 5, len);
}
else {goto __returnLink ;}
/*
if(DEBUG) {
if(strcmp(NodeCurr->dir, "/")) fprintf(stdout, "%s\thttp://%s/%s/%s\n", myanchor, NodeCurr->host, NodeCurr->dir, strcmp(NodeCurr->page, "`")?NodeCurr->page:"");
else fprintf(stdout, "%s\thttp://%s%s%s\n", myanchor, NodeCurr->host, NodeCurr->dir, strcmp(NodeCurr->page, "`")?NodeCurr->page:"");
}
*/
if(strlen(myanchor) > 0) AddChildNode(NodeCurr, myanchor);
if(pc + 1) pa = pc + 1;
}while(pa);
__returnLink:
return;
}
示例10: AAS_UpdateStringIndexes
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_UpdateStringIndexes( int numconfigstrings, char *configstrings[] ) {
int i;
//set string pointers and copy the strings
for ( i = 0; i < numconfigstrings; i++ )
{
if ( configstrings[i] ) {
//if ((*aasworld).configstrings[i]) FreeMemory((*aasworld).configstrings[i]);
( *aasworld ).configstrings[i] = (char *) GetMemory( strlen( configstrings[i] ) + 1 );
strcpy( ( *aasworld ).configstrings[i], configstrings[i] );
} //end if
} //end for
( *aasworld ).indexessetup = qtrue;
} //end of the function AAS_UpdateStringIndexes
示例11: AddThread
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AddThread( void ( *func )(int) ) {
thread_t *thread;
if ( numthreads == 1 ) {
if ( currentnumthreads >= numthreads ) {
return;
}
currentnumthreads++;
func( -1 );
currentnumthreads--;
} //end if
else
{
ThreadLock();
if ( currentnumthreads >= numthreads ) {
ThreadUnlock();
return;
} //end if
//allocate new thread
thread = GetMemory( sizeof( thread_t ) );
if ( !thread ) {
Error( "can't allocate memory for thread\n" );
}
//
thread->threadid = currentthreadid;
thread->handle = CreateThread(
NULL, // LPSECURITY_ATTRIBUTES lpsa,
0, // DWORD cbStack,
(LPTHREAD_START_ROUTINE)func, // LPTHREAD_START_ROUTINE lpStartAddr,
(LPVOID) thread->threadid, // LPVOID lpvThreadParm,
0, // DWORD fdwCreate,
&thread->id );
//add the thread to the end of the list
thread->next = NULL;
if ( lastthread ) {
lastthread->next = thread;
} else { firstthread = thread;}
lastthread = thread;
//
#ifdef THREAD_DEBUG
qprintf( "added thread with id %d\n", thread->threadid );
#endif //THREAD_DEBUG
//
currentnumthreads++;
currentthreadid++;
//
ThreadUnlock();
} //end else
} //end of the function AddThread
示例12: FindFileInPak
//===========================================================================
// returns pointer to file handle
// sets offset to and length of 'filename' in the pak file
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
qboolean FindFileInPak( char *pakfile, char *filename, foundfile_t *file ) {
FILE *fp;
dpackheader_t packheader;
dpackfile_t *packfiles;
int numdirs, i;
char path[MAX_PATH];
//open the pak file
fp = fopen( pakfile, "rb" );
if ( !fp ) {
return false;
} //end if
//read pak header, check for valid pak id and seek to the dir entries
if ( ( fread( &packheader, 1, sizeof( dpackheader_t ), fp ) != sizeof( dpackheader_t ) )
|| ( packheader.ident != IDPAKHEADER )
|| ( fseek( fp, LittleLong( packheader.dirofs ), SEEK_SET ) )
) {
fclose( fp );
return false;
} //end if
//number of dir entries in the pak file
numdirs = LittleLong( packheader.dirlen ) / sizeof( dpackfile_t );
packfiles = (dpackfile_t *) GetMemory( numdirs * sizeof( dpackfile_t ) );
//read the dir entry
if ( fread( packfiles, sizeof( dpackfile_t ), numdirs, fp ) != numdirs ) {
fclose( fp );
FreeMemory( packfiles );
return false;
} //end if
fclose( fp );
//
strcpy( path, filename );
ConvertPath( path );
//find the dir entry in the pak file
for ( i = 0; i < numdirs; i++ )
{
//convert the dir entry name
ConvertPath( packfiles[i].name );
//compare the dir entry name with the filename
if ( Q_strcasecmp( packfiles[i].name, path ) == 0 ) {
strcpy( file->filename, pakfile );
file->offset = LittleLong( packfiles[i].filepos );
file->length = LittleLong( packfiles[i].filelen );
FreeMemory( packfiles );
return true;
} //end if
} //end for
FreeMemory( packfiles );
return false;
} //end of the function FindFileInPak
示例13: PS_CreatePunctuationTable
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void PS_CreatePunctuationTable(script_t *script, punctuation_t *punctuations)
{
int i;
punctuation_t *p, *lastp, *newp;
//get memory for the table
if (!script->punctuationtable)
{
script->punctuationtable = (punctuation_t **)
GetMemory(256 * sizeof(punctuation_t *));
}
memset(script->punctuationtable, 0, 256 * sizeof(punctuation_t *));
//add the punctuations in the list to the punctuation table
for (i = 0; punctuations[i].p; i++)
{
newp = &punctuations[i];
lastp = NULL;
//sort the punctuations in this table entry on length (longer punctuations first)
for (p = script->punctuationtable[(unsigned int) newp->p[0]]; p; p = p->next)
{
if (strlen(p->p) < strlen(newp->p))
{
newp->next = p;
if (lastp)
{
lastp->next = newp;
}
else
{
script->punctuationtable[(unsigned int) newp->p[0]] = newp;
}
break;
} //end if
lastp = p;
} //end for
if (!p)
{
newp->next = NULL;
if (lastp)
{
lastp->next = newp;
}
else
{
script->punctuationtable[(unsigned int) newp->p[0]] = newp;
}
} //end if
} //end for
} //end of the function PS_CreatePunctuationTable
示例14: GetMemory
struct Node *CreateNode(struct Seg *ts, const bbox_t bbox)
{
struct Node *tn;
struct Seg *rights = NULL;
struct Seg *lefts = NULL;
tn = GetMemory( sizeof( struct Node)); /* Create a node*/
DivideSegs(ts,&rights,&lefts,bbox); /* Divide node in two*/
num_nodes++;
tn->x = node_x; /* store node line info*/
tn->y = node_y;
tn->dx = node_dx;
tn->dy = node_dy;
FindLimits(lefts,tn->leftbox); /* Find limits of vertices */
if(IsItConvex(lefts)) /* Check lefthand side*/
{
if (verbosity > 1) Verbose("L");
tn->nextl = CreateNode(lefts,tn->leftbox); /* still segs remaining*/
tn->chleft = 0;
if (verbosity > 1) Verbose("\b");
}
else
{
tn->nextl = NULL;
tn->chleft = CreateSSector(lefts) | 0x8000;
}
FindLimits(rights, tn->rightbox); /* Find limits of vertices*/
if(IsItConvex(rights)) /* Check righthand side*/
{
if (verbosity > 1) Verbose("R");
tn->nextr = CreateNode(rights, tn->rightbox); /* still segs remaining*/
tn->chright = 0;
if (verbosity > 1) Verbose("\b");
}
else
{
tn->nextr = NULL;
tn->chright = CreateSSector(rights) | 0x8000;
}
return tn;
}
示例15: GetMemory
void list<T>::push_back(T t)
{
void* mem = GetMemory(sizeof(node));
node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);
if (tail_) {
tail_->next_ = add;
add->prev_ = tail_;
}
else
head_ = add;
tail_ = add;
++sz_;
}