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


C++ bmalloc函数代码示例

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


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

示例1: obs_enter_graphics

gs_vertbuffer_t *create_uv_vbuffer(uint32_t num_verts, bool add_color) {
	obs_enter_graphics();

	gs_vertbuffer_t *tmp = NULL;
	struct gs_vb_data *vrect = NULL;

	vrect = gs_vbdata_create();
	vrect->num = num_verts;
	vrect->points = (struct vec3 *)bmalloc(sizeof(struct vec3) * num_verts);
	vrect->num_tex = 1;
	vrect->tvarray =
		(struct gs_tvertarray *)bmalloc(sizeof(struct gs_tvertarray));
	vrect->tvarray[0].width = 2;
	vrect->tvarray[0].array = bmalloc(sizeof(struct vec2) * num_verts);
	if (add_color)
		vrect->colors = (uint32_t *)bmalloc
		(sizeof(uint32_t)* num_verts);

	memset(vrect->points, 0, sizeof(struct vec3) * num_verts);
	memset(vrect->tvarray[0].array, 0, sizeof(struct vec2) * num_verts);
	if (add_color)
		memset(vrect->colors, 0, sizeof(uint32_t)* num_verts);

	tmp = gs_vertexbuffer_create(vrect, GS_DYNAMIC);

	if (tmp == NULL) {
		blog(LOG_WARNING, "Couldn't create UV vertex buffer.");
	}

	obs_leave_graphics();
	
	return tmp;
}
开发者ID:AhmedAbdulSalam5,项目名称:obs-studio,代码行数:33,代码来源:obs-convenience.c

示例2: bmalloc

bstr *bstr_new(void)
{
  bstr *str;
  str = bmalloc(sizeof(bstr));
  str->bufsiz = 64;
  str->length = 0;
  str->text = bmalloc(str->bufsiz);
  str->text[0] = '\0';
  return str;
}
开发者ID:dror-g,项目名称:nn-colletion,代码行数:10,代码来源:util.c

示例3: bmalloc

static inline struct source_frame *cache_video(obs_source_t source,
        const struct source_frame *frame)
{
    /* TODO: use an actual cache */
    struct source_frame *new_frame = bmalloc(sizeof(struct source_frame));
    memcpy(new_frame, frame, sizeof(struct source_frame));
    new_frame->data = bmalloc(frame->row_bytes * frame->height);

    return new_frame;
}
开发者ID:BraginWoW,项目名称:obs-studio,代码行数:10,代码来源:obs-source.c

示例4: output_new

/*
 * Allocate a new, empty output struct and call bail if memory allocation
 * fails.
 */
struct output *
output_new(void)
{
    struct output *output;

    output = bmalloc(sizeof(struct output));
    output->count = 0;
    output->allocated = 1;
    output->strings = bmalloc(sizeof(char *));
    output->strings[0] = NULL;
    return output;
}
开发者ID:irush-cs,项目名称:pam-krb5,代码行数:16,代码来源:logging.c

示例5: bzalloc

static void *random_create(obs_data_t settings, obs_source_t source)
{
	struct random_tex *rt = bzalloc(sizeof(struct random_tex));
	uint32_t *pixels = bmalloc(20*20*4);
	size_t x, y;

	for (y = 0; y < 20; y++) {
		for (x = 0; x < 20; x++) {
			uint32_t pixel = 0xFF000000;
			pixel |= (rand()%256);
			pixel |= (rand()%256) << 8;
			pixel |= (rand()%256) << 16;
			//pixel |= 0xFFFFFFFF;
			pixels[y*20 + x] = pixel;
		}
	}

	gs_entercontext(obs_graphics());

	rt->texture = gs_create_texture(20, 20, GS_RGBA, 1,
			(const void**)&pixels, 0);
	bfree(pixels);

	if (!rt->texture) {
		random_destroy(rt);
		return NULL;
	}

	gs_leavecontext();

	UNUSED_PARAMETER(settings);
	UNUSED_PARAMETER(source);
	return rt;
}
开发者ID:GamingAtheist,项目名称:obs-studio,代码行数:34,代码来源:test-random.c

示例6: coreaudio_enum_devices

static void coreaudio_enum_devices(struct device_list *list, bool input)
{
	AudioObjectPropertyAddress addr = {
		kAudioHardwarePropertyDevices,
		kAudioObjectPropertyScopeGlobal,
		kAudioObjectPropertyElementMaster
	};

	UInt32        size = 0;
	UInt32        count;
	OSStatus      stat;
	AudioDeviceID *ids;

	stat = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
			0, NULL, &size);
	if (!enum_success(stat, "get kAudioObjectSystemObject data size"))
		return;

	ids   = bmalloc(size);
	count = size / sizeof(AudioDeviceID);

	stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
			0, NULL, &size, ids);

	if (enum_success(stat, "get kAudioObjectSystemObject data"))
		for (UInt32 i = 0; i < count; i++)
			coreaudio_enum_add_device(list, ids[i], input);

	bfree(ids);
}
开发者ID:gameroast,项目名称:obs-studio,代码行数:30,代码来源:mac-audio.c

示例7: obs_scene_create

obs_scene_t obs_scene_create(const char *name)
{
	struct obs_source *source = bmalloc(sizeof(struct obs_source));
	struct obs_scene  *scene;

	memset(source, 0, sizeof(struct obs_source));
	if (!obs_source_init_handlers(source)) {
		bfree(source);
		return NULL;
	}

	source->settings = obs_data_create();
	scene = scene_create(source->settings, source);
	source->data = scene;

	assert(scene);
	if (!scene) {
		obs_data_release(source->settings);
		bfree(source);
		return NULL;
	}

	source->name  = bstrdup(name);
	source->type  = SOURCE_SCENE;

	scene->source = source;
	obs_source_init(source, &scene_info);
	memcpy(&source->callbacks, &scene_info, sizeof(struct source_info));
	return scene;
}
开发者ID:Tyrrr,项目名称:obs-studio,代码行数:30,代码来源:obs-scene.c

示例8: UNUSED_PARAMETER

/*
 * Create the plugin object
 */
static void *pulse_create(obs_data_t settings, obs_source_t source)
{
	UNUSED_PARAMETER(settings);

	struct pulse_data *data = bmalloc(sizeof(struct pulse_data));
	memset(data, 0, sizeof(struct pulse_data));

	data->source = source;
	data->speakers = SPEAKERS_STEREO;

	blog(LOG_DEBUG, "pulse-input: obs wants '%s'",
		obs_data_getstring(settings, "device_id"));

	/* TODO: use obs-studio icon */
	data->props = pa_proplist_new();
	pa_proplist_sets(data->props, PA_PROP_APPLICATION_NAME,
		"OBS Studio");
	pa_proplist_sets(data->props, PA_PROP_APPLICATION_ICON_NAME,
		"application-exit");
	pa_proplist_sets(data->props, PA_PROP_MEDIA_ROLE,
		"production");

	if (os_event_init(&data->event, OS_EVENT_TYPE_MANUAL) != 0)
		goto fail;
	if (pthread_create(&data->thread, NULL, pulse_thread, data) != 0)
		goto fail;

	return data;

fail:
	pulse_destroy(data);
	return NULL;
}
开发者ID:Jhonthe7th,项目名称:obs-studio,代码行数:36,代码来源:pulse-input.c

示例9: audio_output_open

int audio_output_open(audio_t *audio, media_t media, struct audio_info *info)
{
	struct audio_output *out;

	if (!valid_audio_params(info))
		return AUDIO_OUTPUT_INVALIDPARAM;

	out = bmalloc(sizeof(struct audio_output));
	memset(out, 0, sizeof(struct audio_output));

	memcpy(&out->info, info, sizeof(struct audio_info));
	pthread_mutex_init_value(&out->line_mutex);
	out->media = media;
	out->block_size = get_audio_channels(info->speakers) *
	                  get_audio_bytes_per_channel(info->format);

	if (pthread_mutex_init(&out->line_mutex, NULL) != 0)
		goto fail;
	if (event_init(&out->stop_event, true) != 0)
		goto fail;
	if (!ao_add_to_media(out))
		goto fail;
	if (pthread_create(&out->thread, NULL, audio_thread, out) != 0)
		goto fail;

	out->initialized = true;
	*audio = out;
	return AUDIO_OUTPUT_SUCCESS;

fail:
	audio_output_close(out);
	return AUDIO_OUTPUT_FAIL;
}
开发者ID:Alucard014,项目名称:obs-studio,代码行数:33,代码来源:audio-io.c

示例10: obs_properties_create

obs_properties_t obs_properties_create()
{
	struct obs_properties *list;
	list = bmalloc(sizeof(struct obs_properties));
	memset(list, 0, sizeof(struct obs_properties));
	return list;
}
开发者ID:Tyrrr,项目名称:obs-studio,代码行数:7,代码来源:obs-properties.c

示例11: os_wcs_to_utf8_ptr

size_t os_wcs_to_utf8_ptr(const wchar_t *str, size_t len, char **pstr)
{
	size_t out_len = os_wcs_to_utf8(str, len, NULL);

	*pstr = bmalloc((out_len+1) * sizeof(char));
	return os_wcs_to_utf8(str, out_len, *pstr);
}
开发者ID:Boskosauce,项目名称:obs-studio,代码行数:7,代码来源:platform.c

示例12: os_mbs_to_wcs_ptr

size_t os_mbs_to_wcs_ptr(const char *str, size_t len, wchar_t **pstr)
{
	size_t  out_len = os_mbs_to_wcs(str, len, NULL);

	*pstr = bmalloc((out_len+1) * sizeof(wchar_t));
	return os_mbs_to_wcs(str, out_len, *pstr);
}
开发者ID:Boskosauce,项目名称:obs-studio,代码行数:7,代码来源:platform.c

示例13: bmalloc

static void *scene_create(obs_data_t *settings, struct obs_source *source)
{
	pthread_mutexattr_t attr;
	struct obs_scene *scene = bmalloc(sizeof(struct obs_scene));
	scene->source     = source;
	scene->first_item = NULL;

	signal_handler_add_array(obs_source_get_signal_handler(source),
			obs_scene_signals);

	if (pthread_mutexattr_init(&attr) != 0)
		goto fail;
	if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
		goto fail;
	if (pthread_mutex_init(&scene->audio_mutex, &attr) != 0) {
		blog(LOG_ERROR, "scene_create: Couldn't initialize audio "
				"mutex");
		goto fail;
	}
	if (pthread_mutex_init(&scene->video_mutex, &attr) != 0) {
		blog(LOG_ERROR, "scene_create: Couldn't initialize video "
				"mutex");
		goto fail;
	}

	UNUSED_PARAMETER(settings);
	return scene;

fail:
	pthread_mutexattr_destroy(&attr);
	bfree(scene);
	return NULL;
}
开发者ID:AnthonySuper,项目名称:obs-studio,代码行数:33,代码来源:obs-scene.c

示例14: bmalloc

blistd *blistd_einit(void **vs, int ct) {
    blistd *b = (blistd *) bmalloc(sizeof(blistd));
    if (b == NULL) return NULL;
    int i = 0;
    for (; i < ct; i++) blistd_append(b, vs[i]);
    return b;
}
开发者ID:breily,项目名称:clib,代码行数:7,代码来源:blistd.c

示例15: appendview

static void
appendview(			/* append standard view */
	char	*nm,
	VIEW	*vp
)
{
	FILE	*fp;
					/* check if already in there */
	if (!memcmp(&thisview, vwl[currentview].v, sizeof(VIEW))) {
		error(COMMAND, "view already in standard list");
		return;
	}
					/* append to file */
	if ((fp = fopen(radfile, "a")) == NULL) {
		error(COMMAND, "cannot append rad input file");
		return;
	}
	fputs("view=", fp);
	if (nm != NULL) {
		fputc(' ', fp); fputs(nm, fp);
	}
	fprintview(vp, fp); fputc('\n', fp);
	fclose(fp);
					/* append to our list */
	while (vwl[currentview].v != NULL)
		currentview++;
	if (currentview >= MAXVIEW)
		error(INTERNAL, "too many views in appendview");
	vwl[currentview].v = (VIEW *)bmalloc(sizeof(VIEW));
	*(vwl[currentview].v) = thisview;
	if (nm != NULL)
		vwl[currentview].nam = savqstr(nm);
}
开发者ID:germolinal,项目名称:Schedules,代码行数:33,代码来源:glrad.c


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