本文整理汇总了C++中CMemAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ CMemAlloc函数的具体用法?C++ CMemAlloc怎么用?C++ CMemAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CMemAlloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dw_write
static void dw_write( dw_sectnum section, const void *block, dw_size_t len )
/********************************************************************/
{
unsigned bufnum;
unsigned endbufnum;
C_DW_SECTION *dwsect;
char **newbufptrs;
unsigned bufsize;
char *bufptr;
dwsect = &DWSections[section];
#ifdef __DD__
//int i;
printf( "\nDW_WRITE(%d:%d): offset: %d len: %d ",
section,
dwsect->length,
dwsect->offset,
len );
//for( i = 0 ; i < len; i++ ) {
// printf( "%02x ", (int)((char *)block)[i] );
//}
#endif
bufnum = dwsect->offset / C_DWARF_BUFSIZE;
endbufnum = (dwsect->offset + len) / C_DWARF_BUFSIZE;
if( endbufnum >= dwsect->bufcount ) {
newbufptrs = (char**)CMemAlloc( (endbufnum + 1) * sizeof(char**) );
if( dwsect->bufptrs != NULL ) {
memcpy( newbufptrs,
dwsect->bufptrs,
dwsect->bufcount * sizeof(char**) );
CMemFree( dwsect->bufptrs );
}
dwsect->bufptrs = newbufptrs;
dwsect->bufcount = endbufnum + 1;
}
bufsize = C_DWARF_BUFSIZE - (dwsect->offset % C_DWARF_BUFSIZE);
dwsect->offset += len;
if( dwsect->offset > dwsect->length ) {
dwsect->length = dwsect->offset;
}
while( len != 0 ) {
bufptr = dwsect->bufptrs[bufnum];
if( bufptr == NULL ) {
bufptr = (char *)CMemAlloc( C_DWARF_BUFSIZE );
dwsect->bufptrs[bufnum] = bufptr;
}
bufptr += C_DWARF_BUFSIZE - bufsize;
if( len < bufsize ) bufsize = len;
memcpy( bufptr, block, bufsize );
block = (char *)block + bufsize;
len -= bufsize;
++bufnum; // advance to next buffer
bufsize = C_DWARF_BUFSIZE; // buffer is full size
}
}
示例2: CreateAux
void CreateAux( // CREATE AUX ID
const char *id ) // - id
{
CurrEntry = CMemAlloc( offsetof( AUX_ENTRY, name ) + strlen( id ) + 1 );
strcpy( CurrEntry->name, id );
CurrInfo = CMemAlloc( sizeof( AUX_INFO ) );
// AuxCopy assumes destination is valid
CurrInfo->parms = NULL;
CurrInfo->objname = NULL;
CurrInfo->code = NULL;
}
示例3: CMemAlloc
void *AsmAlloc( size_t amount )
{
void *ptr;
ptr = CMemAlloc( amount );
return( ptr );
}
示例4: PragManyRegSets
void PragManyRegSets( // GET PRAGMA REGISTER SETS
void )
{
hw_reg_set buff[ MAXIMUM_PARMSETS ];
int i;
hw_reg_set list;
hw_reg_set *sets;
list = PragRegList();
i = 0;
while( !HW_CEqual( list, HW_EMPTY ) && ( i != MAXIMUM_PARMSETS ) ) {
buff[ i++ ] = list;
list = PragRegList();
}
if( !HW_CEqual( list, HW_EMPTY ) ) {
CErr1( ERR_TOO_MANY_PARM_SETS );
}
HW_CAsgn( buff[i], HW_EMPTY );
i++;
i *= sizeof( hw_reg_set );
sets = ( hw_reg_set * ) CMemAlloc( i );
memcpy( sets, buff, i );
if( !IsAuxParmsBuiltIn( CurrInfo->parms ) ) {
CMemFree( CurrInfo->parms );
}
CurrInfo->parms = sets;
}
示例5: ChunkSaveData
static void ChunkSaveData( STRCHUNK *pch, const char *data, size_t len )
{
int bytesleft;
int requestbytes;
char *newdata;
bytesleft = pch->maxsize - (pch->cursize+len+1);
if( bytesleft <= 0 ) {
requestbytes = -bytesleft;
if( requestbytes < STRCHUNK_INCREMENT ) {
requestbytes = STRCHUNK_INCREMENT;
}
requestbytes += pch->maxsize;
newdata = CMemAlloc( requestbytes );
if( pch->data ) {
memcpy( newdata, pch->data, pch->cursize );
CMemFree( pch->data );
}
pch->data = newdata;
pch->maxsize = requestbytes;
}
memcpy( pch->data+pch->cursize, data, len );
pch->cursize += len;
pch->data[pch->cursize] = '\0';
}
示例6: PCHInitNames
pch_status PCHInitNames( bool writing )
{
int i;
idname *name;
idname **p;
if( ! writing ) {
return( PCHCB_OK );
}
nameTranslateTable = CMemAlloc( nameCount * sizeof( idname * ) );
p = nameTranslateTable;
for( i = 0; i < NAME_TABLE_HASH; ++i ) {
for( name = hashTable[ i ]; name != NULL; name = name->next ) {
*p = name;
++p;
}
}
qsort( nameTranslateTable, nameCount, sizeof( idname * ), cmpName );
#ifndef NDEBUG
{
int i;
for( i = 1; i < nameCount; ++i ) {
if( nameTranslateTable[i - 1] == nameTranslateTable[i] ) {
CFatal( "two identical names in translation table" );
}
}
}
#endif
nameFlags.no_creates_allowed = TRUE;
return( PCHCB_OK );
}
示例7: getPackArgs
local void getPackArgs( void )
/****************************/
{
struct pack_info *pi;
/* check to make sure it is a numeric token */
if( PragIdRecog( "push" ) ) { /* 29-sep-94 */
pi = (struct pack_info *)CMemAlloc( sizeof( struct pack_info ) );
pi->next = PackInfo;
pi->pack_amount = PackAmount;
PackInfo = pi;
if( CurToken == T_COMMA ) {
PPCTL_ENABLE_MACROS();
NextToken();
PPCTL_DISABLE_MACROS();
if( ExpectingConstant() ) {
SetPackAmount();
}
NextToken();
}
} else if( PragIdRecog( "pop" ) ) {
pi = PackInfo;
if( pi != NULL ) {
PackAmount = pi->pack_amount;
PackInfo = pi->next;
CMemFree( pi );
}
} else {
CErr1( ERR_NOT_A_CONSTANT_EXPR );
}
}
示例8: AddLibraryName
void AddLibraryName( char *name, char priority )
/**********************************************/
{
library_list **new_owner;
library_list **owner;
library_list *lib;
int len;
for( owner = &HeadLibs; (lib = *owner) != NULL; owner = &lib->next ) {
if( lib->libname[0] < priority ) {
break;
}
if( FNAMECMPSTR( lib->libname + 1, name ) == 0 ) {
return;
}
}
new_owner = owner;
for( ; (lib = *owner) != NULL; owner = &lib->next ) {
if( FNAMECMPSTR( lib->libname + 1, name ) == 0 ) {
*owner = lib->next;
break;
}
}
if( lib == NULL ) {
len = strlen( name );
lib = CMemAlloc( offsetof( library_list, libname ) + len + 2 );
memcpy( lib->libname + 1, name, len + 1 );
}
lib->libname[0] = priority;
lib->next = *new_owner;
*new_owner = lib;
}
示例9: CMemAlloc
void *SafeRecurseCpp( func_sr rtn, void *arg )
/********************************************/
/* This code assumes NO parameters on the stack! */
{
#define SAVE_SIZE 512 /* this must be smaller than the stack */
void *savearea;
void *retval;
if( stackavail() < 0x2000 ) { /* stack getting low! */
savearea = CMemAlloc( SAVE_SIZE );
if( savearea != NULL ) {
memcpy( bp(), savearea, SAVE_SIZE );
memcpy( sp(), sp() + SAVE_SIZE, bp() - sp() );
setbp( bp() + SAVE_SIZE );
setsp( sp() + SAVE_SIZE );
retval = rtn( arg );
setsp( sp() - SAVE_SIZE );
memcpy( sp() + SAVE_SIZE, sp(), bp() - sp() - SAVE_SIZE );
setbp( bp() - SAVE_SIZE );
memcpy( savearea, bp(), SAVE_SIZE );
CMemFree( savearea );
return( retval );
}
}
return( rtn( arg ) );
}
示例10: readAuxInfo
static void readAuxInfo( AUX_INFO *i )
{
unsigned len;
PCHReadVar( *i );
AsmSysPCHReadCode( i );
len = PCHGetUInt( i->parms );
if( len != 0 ) {
i->parms = CMemAlloc( len );
PCHRead( i->parms, len );
}
len = PCHGetUInt( i->objname );
if( len != 0 ) {
i->objname = CMemAlloc( len );
PCHRead( i->objname, len );
}
}
示例11: PragAlias
// #pragma alias(id1/"name1", id2/"name2")
//
// Causes linker to replace references to id1/name1 with references
// to id2/name2. Both the alias and the substituted symbol may be defined
// either as a string name or an id of existing symbol.
//
static void PragAlias( void )
/***************************/
{
SYM_HANDLE alias_sym;
SYM_HANDLE subst_sym;
const char *alias_name;
const char *subst_name;
alias_list **alias;
alias_list *new_alias;
alias_name = subst_name = NULL;
alias_sym = subst_sym = NULL;
if( ExpectingToken( T_LEFT_PAREN ) ) {
PPCTL_ENABLE_MACROS();
PPNextToken();
if( CurToken == T_ID ) {
alias_sym = SymLook( HashValue, Buffer );
if( alias_sym == 0 ) {
CErr2p( ERR_UNDECLARED_SYM, Buffer );
}
} else if( CurToken == T_STRING ) {
alias_name = CStrSave( Buffer );
}
PPNextToken();
MustRecog( T_COMMA );
if( CurToken == T_ID ) {
subst_sym = SymLook( HashValue, Buffer );
if( subst_sym == 0 ) {
CErr2p( ERR_UNDECLARED_SYM, Buffer );
}
} else if( CurToken == T_STRING ) {
subst_name = CStrSave( Buffer );
}
PPNextToken();
PPCTL_DISABLE_MACROS();
MustRecog( T_RIGHT_PAREN );
}
/* Add a new alias record - if it's valid - to the list */
if( ( alias_name != NULL || alias_sym != NULL ) && ( subst_name != NULL || subst_sym != NULL ) ) {
for( alias = &AliasHead; *alias != NULL; alias = &(*alias)->next )
; /* nothing to do */
new_alias = (void *)CMemAlloc( sizeof( alias_list ) );
new_alias->next = NULL;
if( alias_name ) {
new_alias->name = alias_name;
} else {
new_alias->a_sym = alias_sym;
}
if( subst_name ) {
new_alias->subst = subst_name;
} else {
new_alias->s_sym = subst_sym;
}
*alias = new_alias;
}
}
示例12: pragIncludeAlias
// form: #pragma include_alias( "alias_name", "real_name" )
// #pragma include_alias( <alias_name>, <real_name> )
//
// (1) causes include directives referencing alias_name to refer
// to real_name instead
//
static void pragIncludeAlias( void )
{
if( ExpectingToken( T_LEFT_PAREN ) ) {
PPCTL_ENABLE_MACROS();
NextToken();
if( CurToken == T_STRING ) {
char *alias_name;
alias_name = CMemAlloc( strlen( Buffer ) + 1 );
strcpy( alias_name, Buffer );
NextToken();
if( ExpectingToken( T_COMMA ) ) {
NextToken();
}
if( CurToken == T_STRING ) {
IAliasAdd( alias_name, Buffer, false );
NextToken();
}
CMemFree( alias_name );
} else if( CurToken == T_LT ) {
char a_buf[82];
char r_buf[82];
a_buf[0] = '\0';
for( ;; ) {
NextToken();
if( CurToken == T_GT ) {
NextToken();
break;
}
if( CurToken == T_NULL ) {
break;
}
strncat( a_buf, Buffer, sizeof( a_buf ) - 2 );
}
if( ExpectingToken( T_COMMA ) ) {
NextToken();
}
if( CurToken == T_LT ) {
r_buf[0] = '\0';
for( ;; ) {
NextToken();
if( CurToken == T_GT ) {
NextToken();
break;
}
if( CurToken == T_NULL ) {
break;
}
strncat( r_buf, Buffer, sizeof( r_buf ) - 2 );
}
IAliasAdd( a_buf, r_buf, true );
}
}
PPCTL_DISABLE_MACROS();
MustRecog( T_RIGHT_PAREN );
}
}
示例13: CMemAlloc
static void *dw_alloc( size_t size )
/**********************************/
{
char *p;
p = CMemAlloc( size );
memset( p, 0xA5, size );
return( p );
}
示例14: CreateAux
void CreateAux( char *id )
/************************/
{
CurrEntry = (aux_entry *)CMemAlloc( offsetof( aux_entry, name ) + strlen( id ) + 1 );
strcpy( CurrEntry->name, id );
#if _CPU == 370
CurrEntry->offset = -1;
#endif
}
示例15: PushEnum
// forms: (1) #pragma enum int
// (2) #pragma enum minimum
// (3) #pragma enum original
// (4) #pragma enum pop
//
// The pragma affects the underlying storage-definition for subsequent
// enum declarations.
//
// (1) make int the underlying storage definition (same as -ei)
// (2) minimize the underlying storage definition (same as no -ei)
// (3) reset back to result of command-line parsing
// (4) restore previous value
//
// 1-3 all push previous value before affecting value
//
static void PushEnum( void ) {
/***************************/
struct enums_info *ei;
ei = CMemAlloc( sizeof( struct enums_info ) );
ei->make_enums = CompFlags.make_enums_an_int;
ei->next = EnumInfo;
EnumInfo = ei;
}