コード例 #1
0
ファイル: h_mgr.cpp プロジェクト: Gallaecio/0ad
static Handle reuse_existing_handle(uintptr_t key, H_Type type, size_t flags)
{
	if(flags & RES_NO_CACHE)
		return 0;

	// object of specified key and type doesn't exist yet
	Handle h = h_find(type, key);
	if(h <= 0)
		return 0;

	HDATA* hd;
	RETURN_STATUS_IF_ERR(h_data_tag_type(h, type, hd));	// h_find means this won't fail

	hd->refs += 1;

	// we are reactivating a closed but cached handle.
	// need to generate a new tag so that copies of the
	// previous handle can no longer access the resource.
	// (we don't need to reset the tag in h_free, because
	// use before this fails due to refs > 0 check in h_user_data).
	if(hd->refs == 1)
	{
		const Tag tag = gen_tag();
		h = handle(h_idx(h), tag);	// can't fail
		hd->h = h;
	}

	return h;
}
コード例 #2
0
ファイル: find_enemy.c プロジェクト: Sconso/Lemipc
void			find(t_info *info)
{
	t_coord		c;
	char		check;
	int			ret;

	if (info->game->players == 0)
		return ;
	c.x = 1;
	c.y = 1;
	check = 0;
	while (check != 2)
	{
		check = 0;
		if ((ret = v_find(info, c))
			|| (ret = h_find(info, c)))
			break ;
		if (info->x + c.x + 1 < info->game->width || info->x - (c.x + 1) >= 0)
			c.x++;
		else
			++check;
		if (info->y + c.y + 1 < info->game->height || info->y - (c.y + 1) >= 0)
			c.y++;
		else
			++check;
	}
	move(info, ret);
}
コード例 #3
0
ファイル: hash.c プロジェクト: vaankiller/ADT
// colision reslove 1 : sperate chainning
void h_insert(const char *s, hashtbl h)
{
	if(!s || !h)
		return ;

	pListNode plist = h_find(s, h);

	if(plist != NULL)
	{
		plist = h->lists[hash(s, h->tblsize)];
		pListNode pinsert = malloc(sizeof(struct ListNode));
		if(!pinsert)
			return ;
		else
		{
			strcmp(pinsert->elem, s);
			pinsert->next = plist->next;
			plist->next = pinsert;
		}
	}
	return;
}