当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_ALLOC函数代码示例

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


在下文中一共展示了CHECK_ALLOC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_param

int
parse_param(void *val, AVP_List** avps) {

    char *p;
    str *s, content;
    AVP_List *mp = NULL;

    //LM_DBG("%.*s\n", content.len, content.s);

    content.s = (char*) val;
    content.len = strlen(content.s);


    p = (char*) pkg_malloc (content.len + 1);
    CHECK_ALLOC(p);

    p[content.len] = '\0';
    memcpy(p, content.s, content.len);

    s = (str*) pkg_malloc(sizeof(str));
    CHECK_ALLOC(s);

    for (;*p != '\0';) {

        mp = (AVP_List*) pkg_malloc (sizeof(AVP_List));
        CHECK_ALLOC(mp);
        mp->next = *avps;
        mp->pv = (pv_spec_p) pkg_malloc (sizeof(pv_spec_t));
        CHECK_ALLOC(mp->pv);

        for (; isspace(*p); p++);
        CHECK_COND(*p != '\0');

        mp->name.s = p;

        for(; isgraph(*p) && *p != '='; p++)
            CHECK_COND(*p != '\0');

        mp->name.len = p - mp->name.s;

        for (; isspace(*p); p++);
        CHECK_COND(*p != '\0' && *p == '=');
        p++;

        //LM_DBG("%.*s\n", mp->name.len, mp->name.s);

        for (; isspace(*p); p++);
        CHECK_COND(*p != '\0' && *p == '$');

        s->s = p;
        s->len = strlen(p);

        p = pv_parse_spec(s, mp->pv);

        for (; isspace(*p); p++);
        *avps = mp;
    }

    return 0;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:60,代码来源:call_control.c

示例2: matrix_map_row

void matrix_map_row(matrix_t* mat, const matrix_row_t* row, const offset_t i) {

    if( matrix_row( mat, i ) != NULL ) {
        //printf(" problem, sir" );
        return;
    }

    // allocate space to copy the row
    size_t copy_size =  (mat->num_mapped_rows+1)*sizeof(mapped_row_t);
    mat->mapped_rows = (mapped_row_t*)realloc( mat->mapped_rows, copy_size );
    CHECK_ALLOC( mat->mapped_rows );

    // setup the mapped row
    copy_size = sizeof(matrix_row_t);
    mapped_row_t* mapped_row = &(mat->mapped_rows[mat->num_mapped_rows]);
    mapped_row->i = i;
    memcpy( &(mapped_row->row), row, copy_size );

    assert( row->num_cells >= 0 );
    assert( row->num_cells <= mat->n );

    // allocate space for the copied cells and copy them
    copy_size = row->num_cells * sizeof(cell_t);
    mapped_row->row.cells = (cell_t*)malloc( copy_size );
    CHECK_ALLOC( mapped_row->row.cells );
    memcpy( mapped_row->row.cells, row->cells, copy_size );


    mat->num_mapped_rows++;

    assert( mat->num_mapped_rows <= mat->m - matrix_num_rows( mat ) );
}
开发者ID:harlanji,项目名称:university-coursework,代码行数:32,代码来源:mpi_matrix.c

示例3: parse_sets_func

int parse_sets_func(unsigned int type, void *val) {

	rad_set_elem *elem;
	char *p = (char*) val, *pp = NULL;
	str content;
	int nr;

	elem = (rad_set_elem*) pkg_malloc (sizeof(rad_set_elem));
	CHECK_ALLOC(elem);

	for (; isspace(*p); p++);
	CHECK_COND(*p != '\0');

	elem->set_name.s = p;

	for(;isgraph(*p) && *p != '='; p++)
	CHECK_COND(*p != '\0');

	elem->set_name.len = p - elem->set_name.s;

	for (; isspace(*p); p++);
	CHECK_COND(*p != '\0' && *p == '=');
	p++;

	for (; isspace(*p); p++);
	CHECK_COND(*p != '\0' && *p == '(');
	p++;
	CHECK_COND(*p != '\0');

	elem->parsed = NULL;
	content.s = p;
	nr = 1;

	for (; *p != '\0'; p++) {
		if (*p == '(')
			nr++;
		if (*p == ')')
			pp = p, nr--;
	}

	CHECK_COND(pp && !nr);

	content.len = (pp - content.s) * sizeof(char);
	set_size++;

	sets = (rad_set_elem**) pkg_realloc (sets, set_size * sizeof(rad_set_elem*));
	CHECK_ALLOC(sets);

	sets[set_size - 1] = elem;

	if (parse_set_content(content, elem)) {
		LM_ERR("malformed modparam %.*s\n",sets[set_size - 1]->set_name.len,
				sets[set_size - 1]->set_name.s);
		return -1;
	}

	return 0;
}
开发者ID:ataillefer,项目名称:opensips,代码行数:58,代码来源:aaa_radius.c

示例4: sennaCreate

/*
 * allocates hash tables labels and provides a pointer to the data structure
 * has to be freed using freeSenna
 */
SENNA* sennaCreate(const char * opt_path) {
    SENNA* senna = (SENNA*) malloc(sizeof(SENNA));
    CHECK_ALLOC(senna);

    senna->word_hash = SENNA_Hash_new(opt_path, "hash/words.lst");
    senna->caps_hash = SENNA_Hash_new(opt_path, "hash/caps.lst");
    senna->suff_hash = SENNA_Hash_new(opt_path, "hash/suffix.lst");
    senna->gazt_hash = SENNA_Hash_new(opt_path, "hash/gazetteer.lst");

    senna->gazl_hash = SENNA_Hash_new_with_admissible_keys(opt_path, "hash/ner.loc.lst", "data/ner.loc.dat");
    senna->gazm_hash = SENNA_Hash_new_with_admissible_keys(opt_path, "hash/ner.msc.lst", "data/ner.msc.dat");
    senna->gazo_hash = SENNA_Hash_new_with_admissible_keys(opt_path, "hash/ner.org.lst", "data/ner.org.dat");
    senna->gazp_hash = SENNA_Hash_new_with_admissible_keys(opt_path, "hash/ner.per.lst", "data/ner.per.dat");

    // labels
    senna->pos_hash = SENNA_Hash_new(opt_path, "hash/pos.lst");
    // senna->chk_hash = SENNA_Hash_new(opt_path, "hash/chk.lst");
    // senna->pt0_hash = SENNA_Hash_new(opt_path, "hash/pt0.lst");
    // senna->ner_hash = SENNA_Hash_new(opt_path, "hash/ner.lst");
    // senna->vbs_hash = SENNA_Hash_new(opt_path, "hash/vbs.lst");
    // senna->srl_hash = SENNA_Hash_new(opt_path, "hash/srl.lst");
    senna->psg_left_hash = SENNA_Hash_new(opt_path, "hash/psg-left.lst");
    senna->psg_right_hash = SENNA_Hash_new(opt_path, "hash/psg-right.lst");

    senna->pos = SENNA_POS_new(opt_path, "data/pos.dat");
    // senna->chk = SENNA_CHK_new(opt_path, "data/chk.dat");
    // senna->pt0 = SENNA_PT0_new(opt_path, "data/pt0.dat");
    // senna->ner = SENNA_NER_new(opt_path, "data/ner.dat");
    // senna->vbs = SENNA_VBS_new(opt_path, "data/vbs.dat");
    // senna->srl = SENNA_SRL_new(opt_path, "data/srl.dat");
    senna->psg = SENNA_PSG_new(opt_path, "data/psg.dat");

    senna->tokenizer = SENNA_Tokenizer_new(
                           senna->word_hash,
                           senna->caps_hash,
                           senna->suff_hash,
                           senna->gazt_hash,
                           senna->gazl_hash,
                           senna->gazm_hash,
                           senna->gazo_hash,
                           senna->gazp_hash,
                           0);

    senna->lastSentence.tokens = NULL;
    senna->lastSentence.pos_labels = NULL;
    senna->lastSentence.psg_labels = NULL;

    senna->strbuf.ptr = (char *) malloc(sizeof(char) * 512);
    CHECK_ALLOC(senna->strbuf.ptr);
    senna->strbuf.length = 512;
    senna->strbuf.pos = 0;

    return senna;
}
开发者ID:jfschaefer,项目名称:rust-senna,代码行数:58,代码来源:c_wrapper.c

示例5: RETURN_ERR

blargg_err_t Nes_Cart::load_patched_ines( Auto_File_Reader in, Auto_File_Reader patch )
{
	RETURN_ERR( in.open() );
	RETURN_ERR( patch.open() );
	
	// read file into memory
	long size = in->remain();
	byte* ines = (byte*) malloc( size );
	CHECK_ALLOC( ines );
	const char* err = in->read( ines, size );
	
	// apply patch
	if ( !err )
		err = apply_ips_patch( *patch, &ines, &size );
	
	// load patched file
	if ( !err )
	{
		Mem_File_Reader patched( ines, size );
		err = load_ines( patched );
	}
	
	free( ines );
	
	return err;
}
开发者ID:Bindernews,项目名称:HeadlessQuickNes,代码行数:26,代码来源:Nes_Cart.cpp

示例6: CVisualPin

CVisualPin* CVisualNode::AddPin(bool fInput, LONG_PTR pData, const CAtlStringW& strLabel, int nPinId)
{
    HRESULT hr;
    CVisualPin* pPin = new CVisualPin(this, 
                            CVisualRect(0, 0, PIN_WIDTH, PIN_HEIGHT), 
                            (fInput) ? CVisualObject::INPUT : CVisualObject::OUTPUT, strLabel, nPinId);
    CHECK_ALLOC( pPin );
    
    pPin->SetData(pData);

    if(fInput)
    {
        m_InputPins.Add(pPin);
    }
    else
    {
        m_OutputPins.Add(pPin);
    }

    pPin->SetHandler(ms_pPinHandler);
   
    RecalcPins();

Cleanup:
    return pPin;
}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:26,代码来源:tedvis.cpp

示例7: gme_set_track_info

gme_err_t gme_set_track_info( Music_Emu * me, gme_info_t* in, int track )
{
	track_info_t* info = BLARGG_NEW track_info_t;
	CHECK_ALLOC( info );
	
#define COPY(name) info->name = in->name;
	
	COPY( length );
	COPY( intro_length );
	COPY( loop_length );
	
#undef COPY
#define COPY(name) if ( in->name ) strncpy( info->name, in->name, sizeof(info->name) - 1 ), info->name[sizeof(info->name)-1] = '\0'; else info->name[0] = '\0';
    
	COPY( system );
	COPY( game );
	COPY( song );
	COPY( author );
	COPY( copyright );
	COPY( comment );
	COPY( dumper );
	
#undef COPY
	
	blargg_err_t err = me->set_track_info( info, track );
    
    delete info;
    
    return err;
}
开发者ID:kode54,项目名称:Cog,代码行数:30,代码来源:gme.cpp

示例8: http_client_on_header_value

static int
http_client_on_header_value(struct http_parser *p, const char *at, size_t sz) {

	struct http_client *c = p->data;
	size_t n = c->header_count;

	/* Add data to the current header value. */
	CHECK_ALLOC(c, c->headers[n-1].val = realloc(c->headers[n-1].val,
			c->headers[n-1].val_sz + sz + 1));
	memcpy(c->headers[n-1].val + c->headers[n-1].val_sz, at, sz);
	c->headers[n-1].val_sz += sz;
	c->headers[n-1].val[c->headers[n-1].val_sz] = 0;

	c->last_cb = LAST_CB_VAL;


	/* react to some values. */
	if(strncmp("Expect", c->headers[n-1].key, c->headers[n-1].key_sz) == 0) {
		if(sz == 12 && strncasecmp(at, "100-continue", sz) == 0) {
			/* support HTTP file upload */
			char http100[] = "HTTP/1.1 100 Continue\r\n\r\n";
			int ret = write(c->fd, http100, sizeof(http100)-1);
			(void)ret;
		}
	} else if(strncasecmp("Connection", c->headers[n-1].key, c->headers[n-1].key_sz) == 0) {
		if(sz == 10 && strncasecmp(at, "Keep-Alive", sz) == 0) {
			c->keep_alive = 1;
		}
	}

	return 0;
}
开发者ID:nicolasff,项目名称:webdis,代码行数:32,代码来源:client.c

示例9: CHECK_ALLOC

blargg_err_t Nes_Blitter::init()
{
	CHECK_ALLOC( ntsc = (nes_ntsc_emph_t*) malloc( sizeof *ntsc ) );
	static setup_t const s = { };
	setup_ = s;
	setup_.ntsc = nes_ntsc_composite;
	return setup( setup_ );
}
开发者ID:xerpi,项目名称:NES4Vita,代码行数:8,代码来源:Nes_Blitter.cpp

示例10: comm_schedule_init

void comm_schedule_init( comm_schedule_t* schedule, MPI_Comm comm ) {
    rank_t p, r;
    MPI_CALL( MPI_Comm_size(comm, &p) );
    MPI_CALL( MPI_Comm_rank(comm, &r) );

    schedule->comm = comm;

    schedule->map_size = p*p*sizeof(offset_t);
    schedule->comm_map = (offset_t*)malloc( schedule->map_size );
    CHECK_ALLOC( schedule->comm_map );
    memset( schedule->comm_map, 0, schedule->map_size );

    schedule->map_size = p*sizeof(offset_t*);
    schedule->recv_cols = (offset_t**)malloc( schedule->map_size );
    CHECK_ALLOC(schedule->recv_cols);
    memset( schedule->recv_cols, 0, schedule->map_size );
}
开发者ID:harlanji,项目名称:university-coursework,代码行数:17,代码来源:mpi_matrix.c

示例11: new_opl_apu

static blargg_err_t new_opl_apu( Opl_Apu::type_t type, Opl_Apu** out )
{
	check( !*out );
	CHECK_ALLOC( *out = BLARGG_NEW( Opl_Apu ) );
	blip_time_t const period = 72;
	int const rate = clock_rate / period;
	return (*out)->init( rate * period, rate, period, type );
}
开发者ID:wbb1977,项目名称:modo_android,代码行数:8,代码来源:Kss_Emu.cpp

示例12: matrix_deserialize

void matrix_deserialize( matrix_t* mat, const char* buf ) {
    size_t offset = 0;
    size_t copy_size = 0;
    // copy matrix
    copy_size = sizeof(matrix_t);
    memcpy( mat, buf, copy_size );
    offset += copy_size;

    // explicitly set this null to avoid problems.
    mat->num_mapped_rows = 0;
    mat->mapped_rows = NULL;

    LOG(LOG_DEBUG, "deserializing matrix... from_i=%lu, to_i=%lu. #=%lu\n", mat->from_i, mat->to_i, matrix_num_rows(mat) );

    // copy rows
    copy_size = matrix_num_rows(mat) * sizeof(matrix_row_t);
    mat->rows = (matrix_row_t*)malloc( copy_size );
    CHECK_ALLOC( mat->rows );
    memset( mat->rows, 0, copy_size );

    memcpy( matrix_row(mat, mat->from_i), buf + offset, copy_size );
    offset += copy_size;

    LOG(LOG_DEBUG, "deserializing matrix... from_i=%lu, to_i=%lu\n", mat->from_i, mat->to_i );

    // copy cells of each row
    offset_t i;
    for( i = mat->from_i; i <= mat->to_i; i++ ) {

        matrix_row_t* row = matrix_row(mat, i);

        assert( row != NULL );
        assert( row->num_cells <= mat->n );


        LOG(LOG_DEBUG, "(%lu) has %lu\n", i, row->num_cells);

        if( row->num_cells > 0 ) {
            copy_size = row->num_cells * sizeof(cell_t);
            row->cells = (cell_t*)malloc( copy_size );
            CHECK_ALLOC( row->cells );
            memcpy( row->cells, buf + offset, row->num_cells * sizeof(cell_t) );
            offset += copy_size;
        }
    }
}
开发者ID:harlanji,项目名称:university-coursework,代码行数:46,代码来源:mpi_matrix.c

示例13: CHECK_ALLOC

blargg_err_t Nes_Vrc7_Apu::init()
{
    CHECK_ALLOC( opll = ym2413_init( 3579545, 3579545 / 72, 1 ) );

    set_output( 0 );
    volume( 1.0 );
    reset();
    return 0;
}
开发者ID:hudokkow,项目名称:audiodecoder.gme,代码行数:9,代码来源:Nes_Vrc7_Apu.cpp

示例14: CHECK_ALLOC

const char * Nes_State_Writer::end( Nes_Emu const& emu )
{
    Nes_State* state = BLARGG_NEW Nes_State;
    CHECK_ALLOC( state );
    emu.save_state( state );
    const char * err = end( *state );
    delete state;
    return err;
}
开发者ID:libretro,项目名称:QuickNES_Core,代码行数:9,代码来源:Nes_State.cpp

示例15: CHECK_ALLOC

blargg_err_t Nes_Emu::save_state( Auto_File_Writer out ) const
{
    Nes_State* state = BLARGG_NEW Nes_State;
    CHECK_ALLOC( state );
    save_state( state );
    blargg_err_t err = state->write( out );
    delete state;
    return err;
}
开发者ID:kode54,项目名称:QuickNES_Core,代码行数:9,代码来源:Nes_Emu.cpp


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