示例#1
0
文件: hog.c 项目: aguedes/bluez
struct bt_hog *bt_hog_new(const char *name, uint16_t vendor, uint16_t product,
					uint16_t version, void *primary)
{
	struct bt_hog *hog;

	hog = g_try_new0(struct bt_hog, 1);
	if (!hog)
		return NULL;

	hog->uhid = bt_uhid_new_default();
	if (!hog->uhid) {
		hog_free(hog);
		return NULL;
	}

	hog->name = g_strdup(name);
	hog->vendor = vendor;
	hog->product = product;
	hog->version = version;

	if (primary)
		hog->primary = g_memdup(primary, sizeof(*hog->primary));

	return bt_hog_ref(hog);
}
示例#2
0
文件: hog.c 项目: aguedes/bluez
void bt_hog_unref(struct bt_hog *hog)
{
	if (!hog)
		return;

	if (__sync_sub_and_fetch(&hog->ref_count, 1))
		return;

	hog_free(hog);
}
示例#3
0
文件: memhog.c 项目: taysom/tau
int main(int argc, char *argv[])
{
	printf("%llu\n", memfree());
	hog_memory(1ULL<<30);
	printf("%llu\n", memfree());
	hog_leave_memory(1<<29);
	printf("%llu\n", memfree());
	{
		int i;

		for (i = 0; i < 7 /*35*/; i++) {
			printf("%d\n", i);
			hog_memory(1ULL<<i);
			hog_free();
		}
	}
	return 0;
}