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

C++ sanity_check函数代码示例

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

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



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

示例1: getGuiEngine

int ModApiMainMenu::l_get_table_index(lua_State *L)
{
	GUIEngine* engine = getGuiEngine(L);
	sanity_check(engine != NULL);

	std::string tablename(luaL_checkstring(L, 1));
	GUITable *table = engine->m_menu->getTable(tablename);
	s32 selection = table ? table->getSelected() : 0;

	if (selection >= 1)
		lua_pushinteger(L, selection);
	else
		lua_pushnil(L);
	return 1;
}
开发者ID:4Evergreen4,项目名称:minetest,代码行数:15,代码来源:l_mainmenu.cpp


示例2: getBlock

    void CodeAlloc::free(NIns* start, NIns *end) {
        CodeList *blk = getBlock(start, end);
        if (verbose)
            avmplus::AvmLog("free %p-%p %d\n", start, end, (int)blk->size());

		AvmAssert(!blk->isFree); 

        // coalesce
        if (blk->lower && blk->lower->isFree) {
            // combine blk into blk->lower (destroy blk)
            CodeList* lower = blk->lower;
            CodeList* higher = blk->higher;
            lower->higher = higher;
            higher->lower = lower;
            debug_only( sanity_check();)
开发者ID:sandys,项目名称:tracemonkey-64bit,代码行数:15,代码来源:CodeAlloc.cpp


示例3: luaL_checknumber

// set_timeofday(val)
// val = 0...1
int ModApiEnvMod::l_set_timeofday(lua_State *L)
{
	GET_ENV_PTR;

	// Do it
	float timeofday_f = luaL_checknumber(L, 1);
	sanity_check(timeofday_f >= 0.0 && timeofday_f <= 1.0);
	int timeofday_mh = (int)(timeofday_f * 24000.0);
	// This should be set directly in the environment but currently
	// such changes aren't immediately sent to the clients, so call
	// the server instead.
	//env->setTimeOfDay(timeofday_mh);
	getServer(L)->setTimeOfDay(timeofday_mh);
	return 0;
}
开发者ID:ultrabots,项目名称:minetest,代码行数:17,代码来源:l_env.cpp


示例4: SWITCH_DECLARE

SWITCH_DECLARE(int) CoreSession::setAutoHangup(bool val) 
{
	this_check(-1);
	sanity_check(-1);

	if (!session) {
		return SWITCH_STATUS_FALSE;
	}	
	if (val) {
		switch_set_flag(this, S_HUP);
	} else {
		switch_clear_flag(this, S_HUP);
	}
	return SWITCH_STATUS_SUCCESS;
}
开发者ID:sl33nyc,项目名称:freeswitch,代码行数:15,代码来源:switch_cpp.cpp


示例5: assert

void Schematic::placeOnMap(ServerMap *map, v3s16 p, u32 flags,
	Rotation rot, bool force_place)
{
	std::map<v3s16, MapBlock *> lighting_modified_blocks;
	std::map<v3s16, MapBlock *> modified_blocks;
	std::map<v3s16, MapBlock *>::iterator it;

	assert(map != NULL);
	assert(schemdata != NULL);
	sanity_check(m_ndef != NULL);

	//// Determine effective rotation and effective schematic dimensions
	if (rot == ROTATE_RAND)
		rot = (Rotation)myrand_range(ROTATE_0, ROTATE_270);

	v3s16 s = (rot == ROTATE_90 || rot == ROTATE_270) ?
			v3s16(size.Z, size.Y, size.X) : size;

	//// Adjust placement position if necessary
	if (flags & DECO_PLACE_CENTER_X)
		p.X -= (s.X + 1) / 2;
	if (flags & DECO_PLACE_CENTER_Y)
		p.Y -= (s.Y + 1) / 2;
	if (flags & DECO_PLACE_CENTER_Z)
		p.Z -= (s.Z + 1) / 2;

	//// Create VManip for effected area, emerge our area, modify area
	//// inside VManip, then blit back.
	v3s16 bp1 = getNodeBlockPos(p);
	v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1,1,1));

	MMVManip vm(map);
	vm.initialEmerge(bp1, bp2);

	blitToVManip(&vm, p, rot, force_place);

	voxalgo::blit_back_with_light(map, &vm, &modified_blocks);

	//// Carry out post-map-modification actions

	//// Create & dispatch map modification events to observers
	MapEditEvent event;
	event.type = MEET_OTHER;
	for (it = modified_blocks.begin(); it != modified_blocks.end(); ++it)
		event.modified_blocks.insert(it->first);

	map->dispatchEvent(&event);
}
开发者ID:CasimirKaPazi,项目名称:minetest,代码行数:48,代码来源:mg_schematic.cpp


示例6: SWITCH_DECLARE

SWITCH_DECLARE(int) CoreSession::flushEvents() 
{
	switch_event_t *event;

	this_check(-1);
	sanity_check(-1);

	if (!session) {
		return SWITCH_STATUS_FALSE;
	}

	while (switch_core_session_dequeue_event(session, &event, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
		switch_event_destroy(&event);
	}
	return SWITCH_STATUS_SUCCESS;
}
开发者ID:odmanV2,项目名称:freecenter,代码行数:16,代码来源:switch_cpp.cpp


示例7: RecursiveMutexAutoLock

void LuaLBM::trigger(ServerEnvironment *env, v3s16 p, MapNode n)
{
	GameScripting *scriptIface = env->getScriptIface();
	auto _script_lock = RecursiveMutexAutoLock(scriptIface->m_luastackmutex, std::try_to_lock);
	if (!_script_lock.owns_lock()) {
		return;
	}
	scriptIface->realityCheck();

	lua_State *L = scriptIface->getStack();
	sanity_check(lua_checkstack(L, 20));
	StackUnroller stack_unroller(L);

	int error_handler = PUSH_ERROR_HANDLER(L);

	// Get registered_lbms
	lua_getglobal(L, "core");
	lua_getfield(L, -1, "registered_lbms");
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_remove(L, -2); // Remove core

	// Get registered_lbms[m_id]
	lua_pushnumber(L, m_id);
	lua_gettable(L, -2);
	//FATAL_ERROR_IF(lua_isnil(L, -1), "Entry with given id not found in registered_lbms table");
	if (lua_isnil(L, -1)) {
		errorstream << "Entry with given id " << m_id << " not found in registered_lbms table" << std::endl;
		return;
	}
	lua_remove(L, -2); // Remove registered_lbms

	scriptIface->setOriginFromTable(-1);

	// Call action
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_getfield(L, -1, "action");
	luaL_checktype(L, -1, LUA_TFUNCTION);
	lua_remove(L, -2); // Remove registered_lbms[m_id]
	push_v3s16(L, p);
	pushnode(L, n, env->getGameDef()->ndef());

	int result = lua_pcall(L, 2, 0, error_handler);
	if (result)
		scriptIface->scriptError(result, "LuaLBM::trigger");

	lua_pop(L, 1); // Pop error handler
}
开发者ID:proller,项目名称:freeminer,代码行数:47,代码来源:l_env.cpp


示例8: w

void editor_map::resize(int width, int height, int x_offset, int y_offset,
	t_translation::t_terrain filler)
{
	int old_w = w();
	int old_h = h();
	if (old_w == width && old_h == height && x_offset == 0 && y_offset == 0) {
		return;
	}

	// Determine the amount of resizing is required
	const int left_resize = -x_offset;
	const int right_resize = (width - old_w) + x_offset;
	const int top_resize = -y_offset;
	const int bottom_resize = (height - old_h) + y_offset;

	if(right_resize > 0) {
		expand_right(right_resize, filler);
	} else if(right_resize < 0) {
		shrink_right(-right_resize);
	}
	if(bottom_resize > 0) {
		expand_bottom(bottom_resize, filler);
	} else if(bottom_resize < 0) {
		shrink_bottom(-bottom_resize);
	}
	if(left_resize > 0) {
		expand_left(left_resize, filler);
	} else if(left_resize < 0) {
		shrink_left(-left_resize);
	}
	if(top_resize > 0) {
		expand_top(top_resize, filler);
	} else if(top_resize < 0) {
		shrink_top(-top_resize);
	}

	// fix the starting positions
	if(x_offset || y_offset) {
		for(size_t i = 0; i < MAX_PLAYERS+1; ++i) {
			if(startingPositions_[i] != map_location()) {
				startingPositions_[i].x -= x_offset;
				startingPositions_[i].y -= y_offset;
			}
		}
	}
	sanity_check();
}
开发者ID:RushilPatel,项目名称:BattleForWesnoth,代码行数:47,代码来源:editor_map.cpp


示例9: check_header

static int __init check_header(void)
{
	const char * reason = NULL;
	int error;

	if ((error = bio_read_page(swp_offset(swsusp_header.swsusp_info), &swsusp_info)))
		return error;

 	/* Is this same machine? */
	if ((reason = sanity_check())) {
		printk(KERN_ERR "swsusp: Resume mismatch: %s\n",reason);
		return -EPERM;
	}
	nr_copy_pages = swsusp_info.image_pages;
	pagedir_order = get_bitmask_order(SUSPEND_PD_PAGES(nr_copy_pages));
	return error;
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:17,代码来源:swsusp.c


示例10: create_libxs_wrapper

status_t create_libxs_wrapper(xen_instance_t *xen)
{
    libxs_wrapper_t *wrapper = &xen->libxsw;

    wrapper->handle = dlopen ("libxenstore.so", RTLD_NOW | RTLD_GLOBAL);
    if ( !wrapper->handle ) {
        fprintf(stderr, "Failed to find a suitable libxenstore.so at any of the standard paths!\n");
        return VMI_FAILURE;
    }

    wrapper->xs_open = dlsym(wrapper->handle, "xs_open");
    wrapper->xs_close = dlsym(wrapper->handle, "xs_close");
    wrapper->xs_directory = dlsym(wrapper->handle, "xs_directory");
    wrapper->xs_read = dlsym(wrapper->handle, "xs_read");

    return sanity_check(xen);
}
开发者ID:bentau,项目名称:libvmi,代码行数:17,代码来源:libxs_wrapper.c


示例11: getGuiEngine

int ModApiMainMenu::l_update_formspec(lua_State *L)
{
	GUIEngine* engine = getGuiEngine(L);
	sanity_check(engine != NULL);

	if (engine->m_startgame)
		return 0;

	//read formspec
	std::string formspec(luaL_checkstring(L, 1));

	if (engine->m_formspecgui != 0) {
		engine->m_formspecgui->setForm(formspec);
	}

	return 0;
}
开发者ID:qtx0213,项目名称:MultiCraft,代码行数:17,代码来源:l_mainmenu.cpp


示例12: SWITCH_DECLARE

SWITCH_DECLARE(char *) CoreSession::getXMLCDR()
{
	
	switch_xml_t cdr;

	this_check((char *)"");
	sanity_check((char *)"");

	switch_safe_free(xml_cdr_text);

	if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
		xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
		switch_xml_free(cdr);
	}

	return (char *) (xml_cdr_text ? xml_cdr_text : "");
}
开发者ID:gujun,项目名称:sscore,代码行数:17,代码来源:switch_cpp.cpp


示例13: assert

void Schematic::placeStructure(Map *map, v3s16 p, u32 flags,
	Rotation rot, bool force_place)
{
	assert(schemdata != NULL); // Pre-condition
	sanity_check(m_ndef != NULL);

	MMVManip *vm = new MMVManip(map);

	if (rot == ROTATE_RAND)
		rot = (Rotation)myrand_range(ROTATE_0, ROTATE_270);

	v3s16 s = (rot == ROTATE_90 || rot == ROTATE_270) ?
				v3s16(size.Z, size.Y, size.X) : size;

	if (flags & DECO_PLACE_CENTER_X)
		p.X -= (s.X + 1) / 2;
	if (flags & DECO_PLACE_CENTER_Y)
		p.Y -= (s.Y + 1) / 2;
	if (flags & DECO_PLACE_CENTER_Z)
		p.Z -= (s.Z + 1) / 2;

	v3s16 bp1 = getNodeBlockPos(p);
	v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1,1,1));
	vm->initialEmerge(bp1, bp2);

	blitToVManip(p, vm, rot, force_place);

	std::map<v3s16, MapBlock *> lighting_modified_blocks;
	std::map<v3s16, MapBlock *> modified_blocks;
	vm->blitBackAll(&modified_blocks);

	// TODO: Optimize this by using Mapgen::calcLighting() instead
	lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
	map->updateLighting(lighting_modified_blocks, modified_blocks);

	MapEditEvent event;
	event.type = MEET_OTHER;
	for (std::map<v3s16, MapBlock *>::iterator
		it = modified_blocks.begin();
		it != modified_blocks.end(); ++it)
		event.modified_blocks.insert(it->first);

	map->dispatchEvent(&event);
}
开发者ID:netinetwalker,项目名称:minetest,代码行数:44,代码来源:mg_schematic.cpp


示例14: sanity_check

void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
		u32 active_object_count, u32 active_object_count_wider)
{
	GameScripting *scriptIface = env->getScriptIface();
	scriptIface->realityCheck();

	lua_State *L = scriptIface->getStack();
	sanity_check(lua_checkstack(L, 20));
	StackUnroller stack_unroller(L);

	lua_pushcfunction(L, script_error_handler);
	int errorhandler = lua_gettop(L);

	// Get registered_abms
	lua_getglobal(L, "core");
	lua_getfield(L, -1, "registered_abms");
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_remove(L, -2); // Remove core

	// Get registered_abms[m_id]
	lua_pushnumber(L, m_id);
	lua_gettable(L, -2);
	if(lua_isnil(L, -1))
		FATAL_ERROR("");
	lua_remove(L, -2); // Remove registered_abms

	scriptIface->setOriginFromTable(-1);

	// Call action
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_getfield(L, -1, "action");
	luaL_checktype(L, -1, LUA_TFUNCTION);
	lua_remove(L, -2); // Remove registered_abms[m_id]
	push_v3s16(L, p);
	pushnode(L, n, env->getGameDef()->ndef());
	lua_pushnumber(L, active_object_count);
	lua_pushnumber(L, active_object_count_wider);

	int result = lua_pcall(L, 4, 0, errorhandler);
	if (result)
		scriptIface->scriptError(result, "LuaABM::trigger");

	lua_pop(L, 1); // Pop error handler
}
开发者ID:JohnWayne1986,项目名称:minetest,代码行数:44,代码来源:l_env.cpp


示例15: ftl_open

void ftl_open(void)
{
    // debugging example 1 - use breakpoint statement!
    /* *(UINT32*)0xFFFFFFFE = 10; */

    /* UINT32 volatile g_break = 0; */
    /* while (g_break == 0); */

	led(0);
    sanity_check();
    //----------------------------------------
    // read scan lists from NAND flash
    // and build bitmap of bad blocks
    //----------------------------------------
	build_bad_blk_list();

    //----------------------------------------
	// If necessary, do low-level format
	// format() should be called after loading scan lists, because format() calls is_bad_block().
    //----------------------------------------
/* 	if (check_format_mark() == FALSE) */
	if (TRUE)
	{
        uart_print("do format");
		format();
        uart_print("end format");
	}
    // load FTL metadata
    else
    {
        load_metadata();
    }
	g_ftl_read_buf_id = 0;
	g_ftl_write_buf_id = 0;

    // This example FTL can handle runtime bad block interrupts and read fail (uncorrectable bit errors) interrupts
    flash_clear_irq();

    SETREG(INTR_MASK, FIRQ_DATA_CORRUPT | FIRQ_BADBLK_L | FIRQ_BADBLK_H);
	SETREG(FCONF_PAUSE, FIRQ_DATA_CORRUPT | FIRQ_BADBLK_L | FIRQ_BADBLK_H);

	enable_irq();
}
开发者ID:ClydeProjects,项目名称:OpenSSD,代码行数:43,代码来源:ftl.c


示例16: check_header

static int __init check_header(void)
{
	const char * reason = NULL;
	int error;

	init_header();

	if ((error = read_page(swp_offset(pmdisk_header.pmdisk_info), 
			       &pmdisk_info)))
		return error;

 	/* Is this same machine? */
	if ((reason = sanity_check())) {
		printk(KERN_ERR "pmdisk: Resume mismatch: %s\n",reason);
		return -EPERM;
	}
	pmdisk_pages = pmdisk_info.image_pages;
	return error;
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:19,代码来源:pmdisk.c


示例17: getSupportedVideoModes

std::vector<core::vector3d<u32> > getSupportedVideoModes()
{
	IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
	sanity_check(nulldevice != NULL);

	std::vector<core::vector3d<u32> > mlist;
	video::IVideoModeList *modelist = nulldevice->getVideoModeList();

	u32 num_modes = modelist->getVideoModeCount();
	for (u32 i = 0; i != num_modes; i++) {
		core::dimension2d<u32> mode_res = modelist->getVideoModeResolution(i);
		s32 mode_depth = modelist->getVideoModeDepth(i);
		mlist.push_back(core::vector3d<u32>(mode_res.Width, mode_res.Height, mode_depth));
	}

	nulldevice->drop();

	return mlist;
}
开发者ID:racam,项目名称:minetest,代码行数:19,代码来源:porting.cpp


示例18: option_parse

/* option_parse(): parse a configuration file
 * @opts    -> the options struct
 * @path    -> an absolute pathname to the file
 * $return  -> 1 on success, 0 otherwise
 *
 * This is the exported function to allow caller to parse a configuration
 * file and populate the provided options structure.
 */
int option_parse(struct options *opts, char *path)
{
	journal_strace("option_parse");

    FILE *fp;
    int i;

    if ((fp = fopen(path, "r")) == NULL) {
	    journal_notice("%s: %s\n", path, strerror(errno));
	    return 1;
    }
    
    for (i = 0; opts[i].tag != NULL; i++)
	    *(void **)opts[i].value = NULL;

    /* XXX This is a proof-of-concept */
    switch(parse(opts, fp)) {
	    case ERR_SYNTAX:
		    journal_notice("option]> syntax error\n");
		    fclose(fp);
		    return ERR_SYNTAX;

	    case ERR_DUPLICATE:
		    journal_notice("option]> duplicate\n");
		    fclose(fp);
		    return ERR_DUPLICATE;

	    case ERR_ERRNO:
		    perror("unexpected error");
		    fclose(fp);
		    return ERR_ERRNO;

	    case ERR_TYPE:
		    journal_notice("option]> invalid option type\n");
		    fclose(fp);
		    return ERR_TYPE;
    }

    fclose(fp);
    return sanity_check(opts);

    /* XXX In all error case, option_free() should be call to free() memory */
}
开发者ID:nicboul,项目名称:xia,代码行数:51,代码来源:options.c


示例19: option_parse

/* option_parse(): parse a configuration file
 * @opts    -> the options struct
 * @path    -> an absolute pathname to the file
 * $return  -> 1 on success, 0 otherwise
 *
 * This is the exported function to allow caller to parse a configuration
 * file and populate the provided options structure.
 */
int option_parse(struct options *opts, char *path)
{
    FILE *fp;
    int i;

    if ((fp = fopen(path, "r")) == NULL) {
        jlog(L_NOTICE, "%s: %s", path, strerror(errno));
        return 1;
    }

    for (i = 0; opts[i].tag != NULL; i++)
        *(void **)opts[i].value = NULL;

    switch(parse(opts, fp)) {
    case ERR_SYNTAX:
        jlog(L_NOTICE, "option]> syntax error :: %s:%i", __FILE__, __LINE__);
        option_free(opts);
        fclose(fp);
        return ERR_SYNTAX;

    case ERR_DUPLICATE:
        jlog(L_NOTICE, "option]> duplicate :: %s:%i", __FILE__, __LINE__);
        option_free(opts);
        fclose(fp);
        return ERR_DUPLICATE;

    case ERR_ERRNO:
        jlog(L_NOTICE, "option]> unexpected error %s :: %s:%i", strerror(errno), __FILE__, __LINE__);
        option_free(opts);
        fclose(fp);
        return ERR_ERRNO;

    case ERR_TYPE:
        jlog(L_NOTICE, "option]> invalid option type :: %s:%i", __FILE__, __LINE__);
        option_free(opts);
        fclose(fp);
        return ERR_TYPE;
    }

    fclose(fp);
    return sanity_check(opts);
}
开发者ID:bvanheu,项目名称:DNDS,代码行数:50,代码来源:options.c


示例20: read_config_file

static bool read_config_file(const Settings &cmd_args)
{
	// Path of configuration file in use
	sanity_check(g_settings_path == "");	// Sanity check

	if (cmd_args.exists("config")) {
		bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
		if (!r) {
			errorstream << "Could not read configuration from \""
			            << cmd_args.get("config") << "\"" << std::endl;
			return false;
		}
		g_settings_path = cmd_args.get("config");
	} else {
		std::vector<std::string> filenames;
		filenames.push_back(porting::path_user + DIR_DELIM + "minetest.conf");
		// Legacy configuration file location
		filenames.push_back(porting::path_user +
				DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");

#if RUN_IN_PLACE
		// Try also from a lower level (to aid having the same configuration
		// for many RUN_IN_PLACE installs)
		filenames.push_back(porting::path_user +
				DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
#endif

		for (size_t i = 0; i < filenames.size(); i++) {
			bool r = g_settings->readConfigFile(filenames[i].c_str());
			if (r) {
				g_settings_path = filenames[i];
				break;
			}
		}

		// If no path found, use the first one (menu creates the file)
		if (g_settings_path == "")
			g_settings_path = filenames[0];
	}

	return true;
}
开发者ID:t0suj4,项目名称:minetest,代码行数:42,代码来源:main.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sarrayAddString函数代码示例发布时间:2022-05-30
下一篇:
C++ samsung_rev函数代码示例发布时间: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