Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory alignment. Cleans up the code a bit.master
parent
6ffcd5e74e
commit
b067440f73
|
@ -37,9 +37,8 @@ indexbuffer_t device_create_indexbuffer(device_t device,
|
|||
enum gs_index_type type, void *indices, size_t num,
|
||||
uint32_t flags)
|
||||
{
|
||||
struct gs_index_buffer *ib = bmalloc(sizeof(struct gs_index_buffer));
|
||||
struct gs_index_buffer *ib = bzalloc(sizeof(struct gs_index_buffer));
|
||||
size_t width = type == GS_UNSIGNED_LONG ? sizeof(long) : sizeof(short);
|
||||
memset(ib, 0, sizeof(struct gs_index_buffer));
|
||||
|
||||
ib->device = device;
|
||||
ib->data = indices;
|
||||
|
|
|
@ -48,8 +48,7 @@ static void gl_get_program_info(GLuint program, const char *file,
|
|||
if (!gl_success("glGetProgramiv") || !info_len)
|
||||
return;
|
||||
|
||||
errors = bmalloc(info_len+1);
|
||||
memset(errors, 0, info_len+1);
|
||||
errors = bzalloc(info_len+1);
|
||||
glGetProgramInfoLog(program, info_len, &chars_written, errors);
|
||||
gl_success("glGetProgramInfoLog");
|
||||
|
||||
|
@ -238,11 +237,10 @@ static bool gl_shader_init(struct gs_shader *shader,
|
|||
static struct gs_shader *shader_create(device_t device, enum shader_type type,
|
||||
const char *shader_str, const char *file, char **error_string)
|
||||
{
|
||||
struct gs_shader *shader = bmalloc(sizeof(struct gs_shader));
|
||||
struct gs_shader *shader = bzalloc(sizeof(struct gs_shader));
|
||||
struct gl_shader_parser glsp;
|
||||
bool success = true;
|
||||
|
||||
memset(shader, 0, sizeof(struct gs_shader));
|
||||
shader->device = device;
|
||||
shader->type = type;
|
||||
|
||||
|
|
|
@ -69,9 +69,7 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
|||
uint32_t height, enum gs_color_format color_format)
|
||||
{
|
||||
struct gs_stage_surface *surf;
|
||||
surf = bmalloc(sizeof(struct gs_stage_surface));
|
||||
memset(surf, 0, sizeof(struct gs_stage_surface));
|
||||
|
||||
surf = bzalloc(sizeof(struct gs_stage_surface));
|
||||
surf->format = color_format;
|
||||
surf->width = width;
|
||||
surf->height = height;
|
||||
|
|
|
@ -169,8 +169,7 @@ void convert_sampler_info(struct gs_sampler_state *sampler,
|
|||
|
||||
device_t device_create(struct gs_init_data *info)
|
||||
{
|
||||
struct gs_device *device = bmalloc(sizeof(struct gs_device));
|
||||
memset(device, 0, sizeof(struct gs_device));
|
||||
struct gs_device *device = bzalloc(sizeof(struct gs_device));
|
||||
|
||||
device->plat = gl_platform_create(device, info);
|
||||
if (!device->plat)
|
||||
|
@ -219,8 +218,7 @@ void device_destroy(device_t device)
|
|||
|
||||
swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info)
|
||||
{
|
||||
struct gs_swap_chain *swap = bmalloc(sizeof(struct gs_swap_chain));
|
||||
memset(swap, 0, sizeof(struct gs_swap_chain));
|
||||
struct gs_swap_chain *swap = bzalloc(sizeof(struct gs_swap_chain));
|
||||
|
||||
swap->device = device;
|
||||
swap->info = *info;
|
||||
|
@ -273,8 +271,7 @@ samplerstate_t device_create_samplerstate(device_t device,
|
|||
{
|
||||
struct gs_sampler_state *sampler;
|
||||
|
||||
sampler = bmalloc(sizeof(struct gs_sampler_state));
|
||||
memset(sampler, 0, sizeof(struct gs_sampler_state));
|
||||
sampler = bzalloc(sizeof(struct gs_sampler_state));
|
||||
sampler->device = device;
|
||||
sampler->ref = 1;
|
||||
|
||||
|
|
|
@ -78,9 +78,7 @@ texture_t device_create_texture(device_t device, uint32_t width,
|
|||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags)
|
||||
{
|
||||
struct gs_texture_2d *tex = bmalloc(sizeof(struct gs_texture_2d));
|
||||
memset(tex, 0, sizeof(struct gs_texture_2d));
|
||||
|
||||
struct gs_texture_2d *tex = bzalloc(sizeof(struct gs_texture_2d));
|
||||
tex->base.device = device;
|
||||
tex->base.type = GS_TEXTURE_2D;
|
||||
tex->base.format = color_format;
|
||||
|
|
|
@ -62,9 +62,7 @@ texture_t device_create_cubetexture(device_t device, uint32_t size,
|
|||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
{
|
||||
struct gs_texture_cube *tex = bmalloc(sizeof(struct gs_texture_cube));
|
||||
memset(tex, 0, sizeof(struct gs_texture_2d));
|
||||
|
||||
struct gs_texture_cube *tex = bzalloc(sizeof(struct gs_texture_cube));
|
||||
tex->base.device = device;
|
||||
tex->base.type = GS_TEXTURE_CUBE;
|
||||
tex->base.format = color_format;
|
||||
|
|
|
@ -79,9 +79,7 @@ static bool create_buffers(struct gs_vertex_buffer *vb)
|
|||
vertbuffer_t device_create_vertexbuffer(device_t device,
|
||||
struct vb_data *data, uint32_t flags)
|
||||
{
|
||||
struct gs_vertex_buffer *vb = bmalloc(sizeof(struct gs_vertex_buffer));
|
||||
memset(vb, 0, sizeof(struct gs_vertex_buffer));
|
||||
|
||||
struct gs_vertex_buffer *vb = bzalloc(sizeof(struct gs_vertex_buffer));
|
||||
vb->device = device;
|
||||
vb->data = data;
|
||||
vb->num = data->num;
|
||||
|
|
|
@ -337,11 +337,10 @@ static inline bool gl_setpixelformat(HDC hdc, int format,
|
|||
|
||||
static struct gl_windowinfo *gl_windowinfo_bare(struct gs_init_data *info)
|
||||
{
|
||||
struct gl_windowinfo *wi = bmalloc(sizeof(struct gl_windowinfo));
|
||||
memset(wi, 0, sizeof(struct gl_windowinfo));
|
||||
|
||||
struct gl_windowinfo *wi = bzalloc(sizeof(struct gl_windowinfo));
|
||||
wi->hwnd = info->window.hwnd;
|
||||
wi->hdc = GetDC(wi->hwnd);
|
||||
|
||||
if (!wi->hdc) {
|
||||
blog(LOG_ERROR, "Unable to get device context from window");
|
||||
bfree(wi);
|
||||
|
@ -375,12 +374,11 @@ void gl_update(device_t device)
|
|||
struct gl_platform *gl_platform_create(device_t device,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
struct gl_platform *plat = bmalloc(sizeof(struct gl_platform));
|
||||
struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
|
||||
struct dummy_context dummy;
|
||||
int pixel_format;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
memset(plat, 0, sizeof(struct gl_platform));
|
||||
memset(&dummy, 0, sizeof(struct dummy_context));
|
||||
|
||||
if (!gl_dummy_context_init(&dummy))
|
||||
|
|
|
@ -57,9 +57,7 @@ extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform)
|
|||
|
||||
extern struct gl_windowinfo *gl_windowinfo_create(struct gs_init_data *info)
|
||||
{
|
||||
struct gl_windowinfo *wi = bmalloc(sizeof(struct gl_windowinfo));
|
||||
memset(wi, 0, sizeof(struct gl_windowinfo));
|
||||
|
||||
struct gl_windowinfo *wi = bzalloc(sizeof(struct gl_windowinfo));
|
||||
wi->id = info->window.id;
|
||||
/* wi->display = info->window.display; */
|
||||
|
||||
|
@ -108,13 +106,11 @@ struct gl_platform *gl_platform_create(device_t device,
|
|||
int num_configs = 0;
|
||||
int error_base = 0, event_base = 0;
|
||||
Display *display = XOpenDisplay(NULL); /* Open default screen */
|
||||
struct gl_platform *plat = bmalloc(sizeof(struct gl_platform));
|
||||
struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
|
||||
GLXFBConfig* configs;
|
||||
|
||||
print_info_stuff(info);
|
||||
|
||||
memset(plat, 0, sizeof(struct gl_platform));
|
||||
|
||||
if (!display) {
|
||||
blog(LOG_ERROR, "Unable to find display. DISPLAY variable "
|
||||
"may not be set correctly.");
|
||||
|
|
|
@ -53,8 +53,7 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
|||
{
|
||||
struct gs_zstencil_buffer *zs;
|
||||
|
||||
zs = bmalloc(sizeof(struct gs_zstencil_buffer));
|
||||
memset(zs, 0, sizeof(struct gs_zstencil_buffer));
|
||||
zs = bzalloc(sizeof(struct gs_zstencil_buffer));
|
||||
zs->format = convert_zstencil_format(format);
|
||||
zs->attachment = get_attachment(format);
|
||||
zs->device = device;
|
||||
|
|
|
@ -111,8 +111,7 @@ int gs_create(graphics_t *pgraphics, const char *module,
|
|||
{
|
||||
int errcode = GS_ERROR_FAIL;
|
||||
|
||||
graphics_t graphics = bmalloc(sizeof(struct graphics_subsystem));
|
||||
memset(graphics, 0, sizeof(struct graphics_subsystem));
|
||||
graphics_t graphics = bzalloc(sizeof(struct graphics_subsystem));
|
||||
pthread_mutex_init_value(&graphics->mutex);
|
||||
|
||||
graphics->module = os_dlopen(module);
|
||||
|
@ -571,11 +570,10 @@ effect_t gs_create_effect_from_file(const char *file, char **error_string)
|
|||
effect_t gs_create_effect(const char *effect_string, const char *filename,
|
||||
char **error_string)
|
||||
{
|
||||
struct gs_effect *effect = bmalloc(sizeof(struct gs_effect));
|
||||
struct gs_effect *effect = bzalloc(sizeof(struct gs_effect));
|
||||
struct effect_parser parser;
|
||||
bool success;
|
||||
|
||||
memset(effect, 0, sizeof(struct gs_effect));
|
||||
effect->graphics = thread_graphics;
|
||||
|
||||
ep_init(&parser);
|
||||
|
|
|
@ -186,9 +186,7 @@ struct vb_data {
|
|||
|
||||
static inline struct vb_data *vbdata_create(void)
|
||||
{
|
||||
struct vb_data *vbd = (struct vb_data*)bmalloc(sizeof(struct vb_data));
|
||||
memset(vbd, 0, sizeof(struct vb_data));
|
||||
return vbd;
|
||||
return (struct vb_data*)bzalloc(sizeof(struct vb_data));
|
||||
}
|
||||
|
||||
static inline void vbdata_destroy(struct vb_data *data)
|
||||
|
|
|
@ -39,9 +39,7 @@ texrender_t texrender_create(enum gs_color_format format,
|
|||
enum gs_zstencil_format zsformat)
|
||||
{
|
||||
struct gs_texture_render *texrender;
|
||||
texrender = bmalloc(sizeof(struct gs_texture_render));
|
||||
memset(texrender, 0, sizeof(struct gs_texture_render));
|
||||
|
||||
texrender = bzalloc(sizeof(struct gs_texture_render));
|
||||
texrender->format = format;
|
||||
texrender->zsformat = zsformat;
|
||||
|
||||
|
|
|
@ -364,8 +364,7 @@ int audio_output_open(audio_t *audio, struct audio_output_info *info)
|
|||
if (!valid_audio_params(info))
|
||||
return AUDIO_OUTPUT_INVALIDPARAM;
|
||||
|
||||
out = bmalloc(sizeof(struct audio_output));
|
||||
memset(out, 0, sizeof(struct audio_output));
|
||||
out = bzalloc(sizeof(struct audio_output));
|
||||
|
||||
memcpy(&out->info, info, sizeof(struct audio_output_info));
|
||||
pthread_mutex_init_value(&out->line_mutex);
|
||||
|
@ -426,8 +425,7 @@ void audio_output_close(audio_t audio)
|
|||
|
||||
audio_line_t audio_output_createline(audio_t audio, const char *name)
|
||||
{
|
||||
struct audio_line *line = bmalloc(sizeof(struct audio_line));
|
||||
memset(line, 0, sizeof(struct audio_line));
|
||||
struct audio_line *line = bzalloc(sizeof(struct audio_line));
|
||||
line->alive = true;
|
||||
line->audio = audio;
|
||||
|
||||
|
|
|
@ -80,10 +80,9 @@ static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
|
|||
audio_resampler_t audio_resampler_create(const struct resample_info *dst,
|
||||
const struct resample_info *src)
|
||||
{
|
||||
struct audio_resampler *rs = bmalloc(sizeof(struct audio_resampler));
|
||||
struct audio_resampler *rs = bzalloc(sizeof(struct audio_resampler));
|
||||
int errcode;
|
||||
|
||||
memset(rs, 0, sizeof(struct audio_resampler));
|
||||
rs->opened = false;
|
||||
rs->input_freq = src->samples_per_sec;
|
||||
rs->input_layout = convert_speaker_layout(src->speakers);
|
||||
|
|
|
@ -120,8 +120,7 @@ int video_output_open(video_t *video, struct video_output_info *info)
|
|||
if (!valid_video_params(info))
|
||||
return VIDEO_OUTPUT_INVALIDPARAM;
|
||||
|
||||
out = bmalloc(sizeof(struct video_output));
|
||||
memset(out, 0, sizeof(struct video_output));
|
||||
out = bzalloc(sizeof(struct video_output));
|
||||
|
||||
memcpy(&out->info, info, sizeof(struct video_output_info));
|
||||
out->frame_time = (uint64_t)(1000000000.0 * (double)info->fps_den /
|
||||
|
|
|
@ -118,8 +118,7 @@ static struct obs_data_item *obs_data_item_create(const char *name,
|
|||
name_size = get_name_align_size(name);
|
||||
total_size = name_size + sizeof(struct obs_data_item) + size;
|
||||
|
||||
item = bmalloc(total_size);
|
||||
memset(item, 0, total_size);
|
||||
item = bzalloc(total_size);
|
||||
|
||||
item->capacity = total_size;
|
||||
item->type = type;
|
||||
|
@ -224,8 +223,7 @@ static inline void obs_data_item_setdata(
|
|||
|
||||
obs_data_t obs_data_create()
|
||||
{
|
||||
struct obs_data *data = bmalloc(sizeof(struct obs_data));
|
||||
memset(data, 0, sizeof(struct obs_data));
|
||||
struct obs_data *data = bzalloc(sizeof(struct obs_data));
|
||||
data->ref = 1;
|
||||
|
||||
return data;
|
||||
|
@ -452,8 +450,7 @@ obs_data_array_t obs_data_getarray(obs_data_t data, const char *name)
|
|||
|
||||
obs_data_array_t obs_data_array_create()
|
||||
{
|
||||
struct obs_data_array *array = bmalloc(sizeof(struct obs_data_array));
|
||||
memset(array, 0, sizeof(struct obs_data_array));
|
||||
struct obs_data_array *array = bzalloc(sizeof(struct obs_data_array));
|
||||
array->ref = 1;
|
||||
|
||||
return array;
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
obs_display_t obs_display_create(struct gs_init_data *graphics_data)
|
||||
{
|
||||
struct obs_display *display = bmalloc(sizeof(struct obs_display));
|
||||
memset(display, 0, sizeof(struct obs_display));
|
||||
struct obs_display *display = bzalloc(sizeof(struct obs_display));
|
||||
|
||||
if (graphics_data) {
|
||||
display->swap = gs_create_swapchain(graphics_data);
|
||||
|
|
|
@ -67,8 +67,7 @@ obs_encoder_t obs_encoder_create(const char *id, const char *name,
|
|||
if (!ei)
|
||||
return NULL;
|
||||
|
||||
encoder = bmalloc(sizeof(struct obs_encoder));
|
||||
memset(encoder, 0, sizeof(struct obs_encoder));
|
||||
encoder = bzalloc(sizeof(struct obs_encoder));
|
||||
encoder->callbacks = *ei;
|
||||
|
||||
if (pthread_mutex_init(&encoder->data_callbacks_mutex, NULL) != 0) {
|
||||
|
|
|
@ -53,8 +53,7 @@ struct obs_properties {
|
|||
obs_properties_t obs_properties_create()
|
||||
{
|
||||
struct obs_properties *list;
|
||||
list = bmalloc(sizeof(struct obs_properties));
|
||||
memset(list, 0, sizeof(struct obs_properties));
|
||||
list = bzalloc(sizeof(struct obs_properties));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -90,9 +89,7 @@ void obs_properties_destroy(obs_properties_t props)
|
|||
obs_category_t obs_properties_add_category(obs_properties_t props,
|
||||
const char *name)
|
||||
{
|
||||
struct obs_category *c = bmalloc(sizeof(struct obs_category));
|
||||
memset(c, 0, sizeof(struct obs_category));
|
||||
|
||||
struct obs_category *c = bzalloc(sizeof(struct obs_category));
|
||||
c->name = name;
|
||||
c->next = props->first_category;
|
||||
props->first_category = c;
|
||||
|
@ -137,9 +134,7 @@ static inline struct obs_property *new_prop(struct obs_category *cat,
|
|||
size_t data_size = get_property_size(type);
|
||||
struct obs_property *p;
|
||||
|
||||
p = bmalloc(sizeof(struct obs_property) + data_size);
|
||||
memset(p, 0, sizeof(struct obs_property) + data_size);
|
||||
|
||||
p = bzalloc(sizeof(struct obs_property) + data_size);
|
||||
p->type = type;
|
||||
p->name = name;
|
||||
p->desc = desc;
|
||||
|
|
|
@ -168,10 +168,9 @@ static const struct source_info scene_info =
|
|||
|
||||
obs_scene_t obs_scene_create(const char *name)
|
||||
{
|
||||
struct obs_source *source = bmalloc(sizeof(struct obs_source));
|
||||
struct obs_source *source = bzalloc(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;
|
||||
|
@ -269,10 +268,9 @@ void obs_scene_enum_items(obs_scene_t scene,
|
|||
obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source)
|
||||
{
|
||||
struct obs_scene_item *last;
|
||||
struct obs_scene_item *item = bmalloc(sizeof(struct obs_scene_item));
|
||||
struct obs_scene_item *item = bzalloc(sizeof(struct obs_scene_item));
|
||||
struct calldata params = {0};
|
||||
|
||||
memset(item, 0, sizeof(struct obs_scene_item));
|
||||
item->source = source;
|
||||
item->visible = true;
|
||||
item->parent = scene;
|
||||
|
|
|
@ -154,8 +154,7 @@ obs_source_t obs_source_create(enum obs_source_type type, const char *id,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
source = bmalloc(sizeof(struct obs_source));
|
||||
memset(source, 0, sizeof(struct obs_source));
|
||||
source = bzalloc(sizeof(struct obs_source));
|
||||
|
||||
if (!obs_source_init_handlers(source))
|
||||
goto fail;
|
||||
|
|
|
@ -298,8 +298,7 @@ static inline bool obs_init_handlers(void)
|
|||
|
||||
static bool obs_init(void)
|
||||
{
|
||||
obs = bmalloc(sizeof(struct obs_core));
|
||||
memset(obs, 0, sizeof(struct obs_core));
|
||||
obs = bzalloc(sizeof(struct obs_core));
|
||||
|
||||
obs_init_data();
|
||||
return obs_init_handlers();
|
||||
|
|
|
@ -606,8 +606,7 @@ static inline struct source_frame *source_frame_create(
|
|||
{
|
||||
struct source_frame *frame;
|
||||
|
||||
frame = (struct source_frame*)bmalloc(sizeof(struct source_frame));
|
||||
memset(frame, 0, sizeof(struct source_frame));
|
||||
frame = (struct source_frame*)bzalloc(sizeof(struct source_frame));
|
||||
source_frame_init(frame, format, width, height);
|
||||
return frame;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,14 @@ EXPORT uint64_t bnum_allocs(void);
|
|||
|
||||
EXPORT void *bmemdup(const void *ptr, size_t size);
|
||||
|
||||
static inline void *bzalloc(size_t size)
|
||||
{
|
||||
void *mem = bmalloc(size);
|
||||
if (mem)
|
||||
memset(mem, 0, size);
|
||||
return mem;
|
||||
}
|
||||
|
||||
static inline char *bstrdup_n(const char *str, size_t n)
|
||||
{
|
||||
char *dup;
|
||||
|
|
|
@ -68,9 +68,7 @@ config_t config_create(const char *file)
|
|||
return NULL;
|
||||
fclose(f);
|
||||
|
||||
config = bmalloc(sizeof(struct config_data));
|
||||
memset(config, 0, sizeof(struct config_data));
|
||||
|
||||
config = bzalloc(sizeof(struct config_data));
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -235,8 +233,7 @@ int config_open(config_t *config, const char *file,
|
|||
if (!config)
|
||||
return CONFIG_ERROR;
|
||||
|
||||
*config = bmalloc(sizeof(struct config_data));
|
||||
memset(*config, 0, sizeof(struct config_data));
|
||||
*config = bzalloc(sizeof(struct config_data));
|
||||
(*config)->file = bstrdup(file);
|
||||
|
||||
errorcode = config_parse(&(*config)->sections, file, always_open);
|
||||
|
|
|
@ -102,21 +102,18 @@ struct text_lookup {
|
|||
static void lookup_createsubnode(const char *lookup_val,
|
||||
struct text_leaf *leaf, struct text_node *node)
|
||||
{
|
||||
struct text_node *new = bmalloc(sizeof(struct text_node));
|
||||
memset(new, 0, sizeof(struct text_node));
|
||||
|
||||
struct text_node *new = bzalloc(sizeof(struct text_node));
|
||||
new->leaf = leaf;
|
||||
new->next = node->first_subnode;
|
||||
dstr_copy(&new->str, lookup_val);
|
||||
|
||||
new->next = node->first_subnode;
|
||||
node->first_subnode = new;
|
||||
}
|
||||
|
||||
static void lookup_splitnode(const char *lookup_val, size_t len,
|
||||
struct text_leaf *leaf, struct text_node *node)
|
||||
{
|
||||
struct text_node *split = bmalloc(sizeof(struct text_node));
|
||||
memset(split, 0, sizeof(struct text_node));
|
||||
struct text_node *split = bzalloc(sizeof(struct text_node));
|
||||
|
||||
dstr_copy(&split->str, node->str.array+len);
|
||||
split->leaf = node->leaf;
|
||||
|
@ -360,8 +357,7 @@ static inline bool lookup_getstring(const char *lookup_val,
|
|||
|
||||
lookup_t text_lookup_create(const char *path)
|
||||
{
|
||||
struct text_lookup *lookup = bmalloc(sizeof(struct text_lookup));
|
||||
memset(lookup, 0, sizeof(struct text_lookup));
|
||||
struct text_lookup *lookup = bzalloc(sizeof(struct text_lookup));
|
||||
|
||||
if (!text_lookup_add(lookup, path)) {
|
||||
bfree(lookup);
|
||||
|
@ -388,10 +384,8 @@ bool text_lookup_add(lookup_t lookup, const char *path)
|
|||
if (!file_str.array)
|
||||
return false;
|
||||
|
||||
if (!lookup->top) {
|
||||
lookup->top = bmalloc(sizeof(struct text_node));
|
||||
memset(lookup->top, 0, sizeof(struct text_node));
|
||||
}
|
||||
if (!lookup->top)
|
||||
lookup->top = bzalloc(sizeof(struct text_node));
|
||||
|
||||
dstr_replace(&file_str, "\r", " ");
|
||||
lookup_addfiledata(lookup, file_str.array);
|
||||
|
|
|
@ -330,9 +330,7 @@ void test_callback(void *param, int bla, const char *format, va_list args)
|
|||
struct ffmpeg_output *ffmpeg_output_create(const char *settings,
|
||||
obs_output_t output)
|
||||
{
|
||||
struct ffmpeg_output *data = bmalloc(sizeof(struct ffmpeg_output));
|
||||
memset(data, 0, sizeof(struct ffmpeg_output));
|
||||
|
||||
struct ffmpeg_output *data = bzalloc(sizeof(struct ffmpeg_output));
|
||||
data->output = output;
|
||||
|
||||
av_log_set_callback(test_callback);
|
||||
|
|
|
@ -23,11 +23,9 @@ static pthread_mutex_t c_mutex;
|
|||
struct desktop_tex *osx_desktop_test_create(const char *settings,
|
||||
obs_source_t source)
|
||||
{
|
||||
struct desktop_tex *rt = bmalloc(sizeof(struct desktop_tex));
|
||||
struct desktop_tex *rt = bzalloc(sizeof(struct desktop_tex));
|
||||
char *effect_file;
|
||||
|
||||
memset(rt, 0, sizeof(struct desktop_tex));
|
||||
|
||||
gs_entercontext(obs_graphics());
|
||||
|
||||
struct gs_sampler_info info = {
|
||||
|
|
|
@ -7,9 +7,8 @@ const char *test_getname(const char *locale)
|
|||
|
||||
struct test_filter *test_create(const char *settings, obs_source_t source)
|
||||
{
|
||||
struct test_filter *tf = bmalloc(sizeof(struct test_filter));
|
||||
struct test_filter *tf = bzalloc(sizeof(struct test_filter));
|
||||
char *effect_file;
|
||||
memset(tf, 0, sizeof(struct test_filter));
|
||||
|
||||
gs_entercontext(obs_graphics());
|
||||
|
||||
|
|
|
@ -8,12 +8,10 @@ const char *random_getname(const char *locale)
|
|||
|
||||
struct random_tex *random_create(const char *settings, obs_source_t source)
|
||||
{
|
||||
struct random_tex *rt = bmalloc(sizeof(struct random_tex));
|
||||
struct random_tex *rt = bzalloc(sizeof(struct random_tex));
|
||||
uint32_t *pixels = bmalloc(20*20*4);
|
||||
size_t x, y;
|
||||
|
||||
memset(rt, 0, sizeof(struct random_tex));
|
||||
|
||||
for (y = 0; y < 20; y++) {
|
||||
for (x = 0; x < 20; x++) {
|
||||
uint32_t pixel = 0xFF000000;
|
||||
|
|
|
@ -52,8 +52,7 @@ const char *sinewave_getname(const char *locale)
|
|||
|
||||
struct sinewave_data *sinewave_create(const char *settings, obs_source_t source)
|
||||
{
|
||||
struct sinewave_data *swd = bmalloc(sizeof(struct sinewave_data));
|
||||
memset(swd, 0, sizeof(struct sinewave_data));
|
||||
struct sinewave_data *swd = bzalloc(sizeof(struct sinewave_data));
|
||||
swd->source = source;
|
||||
|
||||
if (event_init(&swd->event, EVENT_TYPE_MANUAL) != 0)
|
||||
|
|
Loading…
Reference in New Issue