• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CMemAlloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CMemAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ CMemAlloc函数的具体用法?C++ CMemAlloc怎么用?C++ CMemAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CMemAlloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
    }
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:55,代码来源:browsio.c


示例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;
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:11,代码来源:cpragma.c


示例3: CMemAlloc

void *AsmAlloc( size_t amount )
{
    void    *ptr;

    ptr = CMemAlloc( amount );
    return( ptr );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:7,代码来源:asmalloc.c


示例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;
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:27,代码来源:cpragma.c


示例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';
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:25,代码来源:cdump.c


示例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 );
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:31,代码来源:name.c


示例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 );
    }
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:31,代码来源:cpragma.c


示例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;
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:32,代码来源:cpragma.c


示例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 ) );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:27,代码来源:stacksr.c


示例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 );
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:17,代码来源:caux.c


示例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;
    }
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:64,代码来源:cpragma.c


示例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 );
    }
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:64,代码来源:cpragma.c


示例13: CMemAlloc

static void *dw_alloc( size_t size )
/**********************************/
{
    char        *p;

    p = CMemAlloc( size );
    memset( p, 0xA5, size );
    return( p );
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:9,代码来源:browsio.c


示例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
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:9,代码来源:cpragma.c


示例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;
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:24,代码来源:cpragma.c


示例16: macroStorageAlloc

static void macroStorageAlloc( void )
{
    macroHashTable = CMemAlloc( HASH_TABLE_SIZE );
    memset( macroHashTable, 0, HASH_TABLE_SIZE );
    macroSegmentList = NULL;
    beforeIncludeChecks = NULL;
    undefCount = 0;
    MacroOffset = NULL;
    macroSegmentLimit = 0;
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:10,代码来源:cmacadd.c


示例17: CMemAlloc

char *vctsave(                  // ALLOCATE AND SAVE VECTOR AS STRING
    const char *vector,         // - source vector
    size_t vsize )              // - size of source vector
{
    char * new_str;             // - target string

    new_str = (char *) CMemAlloc( vsize + 1 );
    stvcpy( new_str, vector, vsize );
    return( new_str );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:10,代码来源:utility.c


示例18: PCHReadPragmas

pch_status PCHReadPragmas( void )
{
    unsigned    size;
    unsigned    max_index;
    unsigned    entry_len;
    unsigned    index;
    AUX_ENTRY   *e;
    AUX_ENTRY   *f;
    AUX_ENTRY   *next_f;
    AUX_INFO    *info;

    for( f = AuxList; f != NULL; f = next_f ) {
        next_f = f->next;
        freeAuxInfo( f->info );
        CMemFree( f->info );
        CMemFree( f );
    }
    max_index = PCHReadUInt();
    size = max_index * sizeof( AUX_INFO * );
    infoTranslate = CMemAlloc( size );
    memset( infoTranslate, 0, size );
    // read all aux_info
    for( index = PCH_FIRST_INDEX; index < max_index; ++index ) {
        if( index < PCH_FIRST_USER_INDEX ) {
            info = BuiltinAuxInfo + index - PCH_FIRST_INDEX;
        } else {
            info = CMemAlloc( sizeof( AUX_INFO ) );
        }
        infoTranslate[index] = info;
        readAuxInfo( info );
    }
    // read aux entries
    AuxList = NULL;
    for( ; (entry_len = PCHReadUInt()) != 0; ) {
        e = CMemAlloc( offsetof( AUX_ENTRY, name ) + entry_len + 1 );
        PCHRead( e->name, entry_len + 1 );
        e->info = PragmaMapIndex( PCHSetUInt( PCHReadUInt() ) );
        e->next = AuxList;
        AuxList = e;
    }
    return( PCHCB_OK );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:42,代码来源:caux.c


示例19: CmdLnCtxPushEnv

void CmdLnCtxPushEnv(           // PUSH FOR ENVIRONMENT-VARIABLE PROCESSING
    char const *var )           // - environment variable
{
    CTX_CL* entry;              // - new entry
    size_t size;                // - variable size

    entry = cmdLnCtxAlloc( CTX_CLTYPE_ENV );
    size = strlen( var ) + 1;
    entry->env.var = CMemAlloc( size );
    memcpy( (void*)entry->env.var, var, size );
}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:11,代码来源:cmdlnctx.c


示例20: strlen

char *AddUndefName( const char *str )
{
    size_t          len;
    undef_names     *uname;

    len = strlen( str );
    if( len == 0 ) {
        CompFlags.undefine_all_macros = 1;
    } else {
        CalcHash( str, len );
        if( !MacroDel( str ) ) {
            uname = (undef_names *)CMemAlloc( sizeof( undef_names ) );
            uname->next = UndefNames;
            uname->name = CMemAlloc( len + 1 );
            memcpy( uname->name, str, len + 1 );
            UndefNames = uname;
            str += len;
        }
    }
    return( (char *)str );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:21,代码来源:cmodel.c



注:本文中的CMemAlloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CMemFree函数代码示例发布时间:2022-05-30
下一篇:
C++ CMargTest函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap