a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit d1d0786bbae5fdd2b7ecd6625769d842f0832672
parent ffc5a9b5c93c58d9655534f127683582560e6b9c
Author: amin <dev@aminmesbah.com>
Date:   Wed,  3 Apr 2019 03:57:28 +0000

Don't heap allocate because there is no need

FossilOrigin-Name: 3a7530c15daa0ed6e892ab171565c3d8e3dd8866b0612ec5b9713664a2732222
Diffstat:
Msrc/shader.c | 14+++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/shader.c b/src/shader.c @@ -144,17 +144,9 @@ void shader_setm4(struct Shader *s, char *name, m4 *mat) { if (s) { - f32* valueptr = malloc(sizeof(m4)); - if (valueptr) - { - glmth_m4_valueptr(*mat, valueptr); - glUniformMatrix4fv(glGetUniformLocation(s->program, name), 1, GL_TRUE, valueptr); - free(valueptr); - } - else - { - printf("Error: Allocation failed\n"); - } + f32 valueptr[sizeof(m4)]; + glmth_m4_valueptr(*mat, valueptr); + glUniformMatrix4fv(glGetUniformLocation(s->program, name), 1, GL_TRUE, valueptr); } else {