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


C++ check_block函数代码示例

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


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

示例1: nvm_set_parameter

int nvm_set_parameter(const char *key, const char *value)
{
	int env_valid = 0;
	int isEnv1Bad = -1;
	int isEnv2Bad = -1;
	int opt_sts = CMM_SUCCESS;
	
	env_t *env_ptr = NULL;	

	isEnv1Bad = check_block("/dev/mtd2", 0);
	isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);

	if( -1 == isEnv1Bad )
	{
		printf("	ERROR: check env block 1 failed\n");
		return CMM_FAILED;
	}
	if( -1 == isEnv2Bad )
	{
		printf("	ERROR: check env block 2 failed\n");
		return CMM_FAILED;
	}

	/* either env1 or env2 is bad block, we do not permit set operation */
	if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
	{
		printf("	ERROR: env is broken\n");
		return CMM_FAILED;
	}

	/* Get NVM */
	env_ptr = env_init(&env_valid);
	if( NULL == env_ptr )
	{
		printf("	ERROR: read env failed\n");
		return CMM_FAILED;
	}

	/* modify ethaddr */
	__do_env_set_parameter(env_ptr, key, value);

	/* update env crc */
	__env_crc_update(env_ptr);
	
	/* save env to flash */
	if( CMM_SUCCESS != __save_env(env_ptr, env_valid) )
	{
		printf("	ERROR: save env failed\n\n");
		opt_sts = CMM_FAILED;
	}
	else
	{		
		opt_sts = CMM_SUCCESS;
	}

	/* free env_ptr malloced by function env_init() */
	env_destroy(env_ptr);	
	return opt_sts;
}
开发者ID:Undrizzle,项目名称:apps,代码行数:59,代码来源:nvm-utils.c

示例2: nvm_dump

void nvm_dump(void)
{
	int env_valid = 0;
	int isEnv1Bad = -1;
	int isEnv2Bad = -1;
	
	struct mtd_info_user info;

	env_t *env_ptr = NULL;

	if( CMM_SUCCESS != get_mtd_info("/dev/mtd2", &info) )
	{
		printf("	ERROR: can not get mtd info\n");
		return;
	}
	
	isEnv1Bad = check_block("/dev/mtd2", 0);
	isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);

	if( -1 == isEnv1Bad )
	{
		printf("	ERROR: check env block 1 failed\n");
		return;
	}
	if( -1 == isEnv2Bad )
	{
		printf("	ERROR: check env block 2 failed\n");
		return;
	}

	if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
	{
		printf("	ERROR: env is broken\n");
		return;
	}

	env_ptr = env_init(&env_valid);
	if( NULL == env_ptr )
	{
		printf("	ERROR: read env failed\n");
		return;
	}

	printf("nvm device name:	mtd2\n");
	printf("device type:		%d\n", info.type);
	printf("nvm total size:		%d KiB\n", info.size/1024);
	printf("block size:		%d KiB\n", info.erasesize/1024);
	printf("page size:		%d KiB\n", info.writesize/1024);
	printf("oob size:		%d bytes\n", info.oobsize);
	printf("bad blocks:		0\n");
	printf("env config size:	%d KiB\n", CFG_ENV_SIZE/1024);
	printf("env valid:		%d\n", env_valid);

	__debug_printf_env(env_ptr);
	
	env_destroy(env_ptr);
}
开发者ID:Undrizzle,项目名称:apps,代码行数:57,代码来源:nvm-utils.c

示例3: release_block

static x_boolean release_block(t_mchecker mc, t_block b, x_boolean stop, x_boolean discard) {

  x_boolean result;

  result = check_block(b, stop);
  
  x_mutex_lock(test_mutex, x_eternal);

  x_list_remove(b);
  decrement_count(b, b->size);

  if (discard) {
    total_discarded += 1;
    if (total_discarded % 1000 == 0) {
      oempa("Discarding Wonka Chunk %d...\n", total_discarded);
    }
    discardMem(b);
  }
  else {
    releaseMem(b);
  }

  x_mutex_unlock(test_mutex);

  return result;
  
}
开发者ID:caizongchao,项目名称:open-mika,代码行数:27,代码来源:ts-mem-test.c

示例4: kfree

void kfree(void* address)
{
	kdebug("< kfree %d", address);

	// start of block
	malloc_block_t* block = address - (uint32_t)&(((malloc_block_t*)0)->data);
	check_block(block);
	
	int size = block->size;
	int flags = block->flags & ~MALLOC_USED;

	// if next block is free, merge with it
	if ((block->flags&MALLOC_LAST)==0) {
		malloc_block_t* next = BLOCK_NEXT(block);
		if ((next->flags&MALLOC_USED)==0) {
			size += next->size;
			flags |= (next->flags&MALLOC_LAST);
		}
	}
	// if previous block is free, merge with it
	if ((block->flags&MALLOC_FIRST)==0) {
		malloc_block_t* prev = BLOCK_PREVIOUS(block);
		if ((prev->flags&MALLOC_USED)==0) {
			size += prev->size;
			flags |= (prev->flags&MALLOC_FIRST);
			block = prev;
		}
	}

	setup_block(block, flags, size);
	kmalloc_print();
	kdebug(">");
}
开发者ID:ben0109,项目名称:MyOS,代码行数:33,代码来源:kmalloc.c

示例5: check_format

int		check_format(const char *format)
{
    t_struct	form;
    int			i;

    i = 0;
    init_struct(&form);
    while ((check_options(format[i], &form)) == 1)
        i++;
    while ((check_minimal_large(format[i], &form)) == 1)
        i++;
    if (format[i] == '.')
    {
        form.prec = 0;
        while ((check_precision(format[++i], &form)) == 1)
            continue;
    }
    while (format[i] == 'h' || format[i] == 'l' || format[i] == 'j'
            || format[i] == 'z')
    {
        check_size_modifier(format + i, &form);
        i++;
        if ((&form)->hh > 0 || (&form)->ll > 0)
            i++;
    }
    check_type(format[i]) == 1 ? (&form)->type = format[i] : 0;
    return (check_block(ft_strsub(format, 0, i + 1), &form));
}
开发者ID:John-Goss,项目名称:Printf,代码行数:28,代码来源:check_format.c

示例6: balls_update

void		balls_update(t_ball *ball, float size)
{
	float min;
	float max;
	float b_min;
	float b_max;

	min = -1.0f + 0.03f;
	max = 1.0f - 0.03f;
	b_min = ball->player->bar.position;
	b_max = ball->player->bar.position + size;
	ball->position.x += ball->direction.x * ball->speed;
	ball->position.y += ball->direction.y * ball->speed;
	check_block(ball);
	if (ball->position.x <= min)
		bounce(1, ball);
	if (ball->position.x >= max)
		bounce(1, ball);
	if (ball->position.x + 0.03f >= b_min && ball->position.x - 0.03f <= b_max)
		bounce_bar(b_min, b_max, ball);
	if (ball->position.y <= min)
		lost(ball);
	if (ball->position.y >= max)
	{
		ball->direction.y *= -1;
		ball->position.y += ball->direction.y * ball->speed;
	}
}
开发者ID:arthurmaurer,项目名称:42-Arkanoid,代码行数:28,代码来源:update2.c

示例7: getFirstBlock

int fileSys::delBlock(string file, int block_number){
	int i,first_blk = getFirstBlock(file);
	
	if(check_n_pad(file) == 0)
		return 0;

	if(check_block(block_number, file) == 0)
		return 0;
	
	//check if the block_number belongs to the file
	if(first_blk == block_number){
		for(i = 0; i < firstBlock.size(); i++){
			if(firstBlock[i] == block_number){
				firstBlock[i] = fat[block_number];
				fat[block_number] = fat[0];
				fat[0] = block_number;
				break; 
			}
		}
	}else{
		for(i = 0; i < fat.size();i++){
			if(fat[i] == block_number){
				fat[i] = fat[block_number];
				fat[block_number] = fat[0];
				fat[0] = block_number;
				break;
			}
		}
	}

	fsSynch();
	return 1;
}
开发者ID:akamel001,项目名称:File-System,代码行数:33,代码来源:fileSys.cpp

示例8: putBlock

int fileSys::putBlock(string file, int block_number, string buffer){
	
	if(check_block(block_number, file) == 0)
		return 0;
	
	disk.putblock(block_number, buffer);
	return 1;
}
开发者ID:akamel001,项目名称:File-System,代码行数:8,代码来源:fileSys.cpp

示例9: check_new_blocks

static void
check_new_blocks(const char *file, int line)
{
	int i = CRT_NEW_TO_CHECK;

	while (i-- > 0)
		check_block(just_touched[i], file, line);
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:8,代码来源:crt_malloc.c

示例10: CrT_check_everything

int
CrT_check_everything(const char *file, int line)
{
	Header m = root.next;
	int i = 0;;
	for (; m != &root; ++i, m = m->next)
		check_block(m, file, line);
	return i;
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:9,代码来源:crt_malloc.c

示例11: m_alloc_usable_size

unsigned m_alloc_usable_size(void *v)
{
	struct alloc_block *ab;
	if (v==NULL) return 0;
	ab = (struct alloc_block *)((char *)v - (unsigned)&((struct alloc_block*)NULL)->content);
	if (!check_block("Check", ab))
		return 0;
	return ab->size;
}
开发者ID:BackupTheBerlios,项目名称:boxcore,代码行数:9,代码来源:m_alloc.cpp

示例12: nvm_get_parameter

int nvm_get_parameter(const char *key, char *value)
{
	int env_valid = 0;
	int isEnv1Bad = -1;
	int isEnv2Bad = -1;
	
	env_t *env_ptr = NULL;	

	isEnv1Bad = check_block("/dev/mtd2", 0);
	isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);

	if( -1 == isEnv1Bad )
	{
		printf("	ERROR: check env block 1 failed\n");
		return CMM_FAILED;
	}
	if( -1 == isEnv2Bad )
	{
		printf("	ERROR: check env block 2 failed\n");
		return CMM_FAILED;
	}

	/* either env1 or env2 is bad block, we do not permit set operation */
	if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
	{
		printf("	ERROR: env is broken\n");
		return CMM_FAILED;
	}

	/* Get NVM */
	env_ptr = env_init(&env_valid);
	if( NULL == env_ptr )
	{
		printf("	ERROR: read env failed\n");
		return CMM_FAILED;
	}

	/* get parameter */
	__do_env_get_parameter(env_ptr, key, value);	

	/* free env_ptr malloced by function env_init() */
	env_destroy(env_ptr);	
	return CMM_SUCCESS;
}
开发者ID:Undrizzle,项目名称:apps,代码行数:44,代码来源:nvm-utils.c

示例13: check_old_blocks

static void
check_old_blocks(const char *file, int line)
{
	int i = CRT_OLD_TO_CHECK;

	while (i-- > 0) {
		check_block(rover, file, line);
		rover = rover->next;
	}
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:10,代码来源:crt_malloc.c

示例14: nextBlock

int fileSys::nextBlock(string file, int block_number){
	
	if(check_n_pad(file) == 0)
		return -1;
	
	if(check_block(block_number, file) == 0)
		return -1;
	
	return fat[block_number];
}
开发者ID:akamel001,项目名称:File-System,代码行数:10,代码来源:fileSys.cpp

示例15: m_alloc_check_memory

void m_alloc_check_memory(void)
{
	int i;
	for (i = 0; i < HASH_SIZE; i++)
	{
		struct alloc_block *ab = SA[i];
		while (ab)
		{
			check_block("check", ab);
			ab = ab->next;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:boxcore,代码行数:13,代码来源:m_alloc.cpp


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