Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory alignment. Cleans up the code a bit.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user