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

C++ bmalloc函数代码示例

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

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



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


示例16: bmalloc

char *read_line(HANDLE hin)
{
  char *buf;
  int bufsize = 32, strind = 0;
  DWORD bytes_read;

  buf = bmalloc(bufsize);

  while (1) {
    if (!ReadFile(hin, &buf[strind], 1, &bytes_read, NULL)) {
      printf("Read error\n");
      break;
    }
    if (bytes_read == 0) {
      buf[strind] = '\0';
      break;
    } else if (buf[strind] == '\r')
      continue;
    else if (buf[strind] == '\n') {
      buf[strind++] = '\0';
      break;
    } else {
      strind++;
      if (strind >= bufsize) {
        bufsize *= 2;
        buf = brealloc(buf, bufsize);
      }
    }
  }
  if (strind == 0) {
    bfree(buf);
    return NULL;
  } else
    return buf;
}
开发者ID:dror-g,项目名称:nn-colletion,代码行数:35,代码来源:makeinstall.c


示例17: lex_get_token

static BSR *store_fileregex(LEX *lc, BSR *bsr)
{
   int token;
   int rc;

   token = lex_get_token(lc, T_STRING);
   if (token == T_ERROR) {
      return NULL;
   }

   if (bsr->fileregex) free(bsr->fileregex);
   bsr->fileregex = bstrdup(lc->str);

   if (bsr->fileregex_re == NULL)
      bsr->fileregex_re = (regex_t *)bmalloc(sizeof(regex_t));

   rc = regcomp(bsr->fileregex_re, bsr->fileregex, REG_EXTENDED|REG_NOSUB);
   if (rc != 0) {
      char prbuf[500];
      regerror(rc, bsr->fileregex_re, prbuf, sizeof(prbuf));
      Emsg2(M_ERROR, 0, _("REGEX '%s' compile error. ERR=%s\n"),
            bsr->fileregex, prbuf);
      return NULL;
   }
   return bsr;
}
开发者ID:AlD,项目名称:bareos,代码行数:26,代码来源:parse_bsr.c


示例18: obs_module_file

void *fade_create(obs_data_t *settings, obs_source_t *source)
{
    struct fade_info *fade;
    char *file = obs_module_file("fade_transition.effect");
    gs_effect_t *effect;

    obs_enter_graphics();
    effect = gs_effect_create_from_file(file, NULL);
    obs_leave_graphics();
    bfree(file);

    if (!effect) {
        blog(LOG_ERROR, "Could not find fade_transition.effect");
        return NULL;
    }

    fade = bmalloc(sizeof(*fade));
    fade->source = source;
    fade->effect = effect;
    fade->a_param = gs_effect_get_param_by_name(effect, "tex_a");
    fade->b_param = gs_effect_get_param_by_name(effect, "tex_b");
    fade->fade_param = gs_effect_get_param_by_name(effect, "fade_val");

    UNUSED_PARAMETER(settings);
    return fade;
}
开发者ID:ab22,项目名称:obs-studio,代码行数:26,代码来源:transition-fade.c


示例19: savqstr

char *
savqstr(char *s)			/* save a private string */
{
	static char  *curp = NULL;		/* allocated memory pointer */
	static unsigned  nrem = 0;		/* bytes remaining in block */
	static unsigned  nextalloc = MINBLOCK;	/* next block size */
	char  *cp;
	unsigned  n;

	for (cp = s; *cp++; )			/* compute strlen()+1 */
		;
	if ((n = cp-s) > nrem) {		/* do we need more core? */
		bfree(curp, nrem);			/* free remnant */
		while (n > nextalloc)
			nextalloc <<= 1;
		if ((curp = bmalloc(nrem=nextalloc)) == NULL) {
			eputs("out of memory in savqstr");
			quit(1);
		}
		if ((nextalloc <<= 1) > MAXBLOCK)	/* double block size */
			nextalloc = MAXBLOCK;
	}
	for (cp = curp; *cp++ = *s++; )		/* inline strcpy() */
		;
	s = curp;				/* update allocation info. */
	curp = cp;
	nrem -= n;
	return(s);				/* return new location */
}
开发者ID:MITSustainableDesignLab,项目名称:Daysim,代码行数:29,代码来源:savqstr.c


示例20: os_fread_mbs

size_t os_fread_mbs(FILE *file, char **pstr)
{
	size_t size = 0;
	size_t len = 0;

	fseeko(file, 0, SEEK_END);
	size = (size_t)ftello(file);
	*pstr = NULL;

	if (size > 0) {
		char *mbstr = bmalloc(size+1);

		fseeko(file, 0, SEEK_SET);
		size = fread(mbstr, 1, size, file);
		if (size == 0) {
			bfree(mbstr);
			return 0;
		}

		mbstr[size] = 0;
		len = os_mbs_to_utf8(mbstr, size, pstr);
		bfree(mbstr);
	}

	return len;
}
开发者ID:gameroast,项目名称:obs-studio,代码行数:26,代码来源:platform.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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