Add loaded shader fragments into registry

This commit is contained in:
Kienan Stewart 2020-02-06 23:32:00 -05:00
parent a22f719ea8
commit d481aa4d19
1 changed files with 3 additions and 1 deletions

View File

@ -39,7 +39,8 @@ struct ShaderRegistry {
void register_shader(struct ShaderRegistry *r, char *name, int type, GLuint id) {
// Allocate storage for the name
int name_size = strlen(name);
char *n = (char*) malloc(name_size * sizeof(char));
char *n = (char*) calloc(name_size, sizeof(char));
strncpy(n, name, strlen(name));
// Grow and copy
int new_size = r->size + 1;
@ -220,6 +221,7 @@ int loadShadersFromFile(const char* file_path, struct ShaderRegistry *registry)
}
// Add to registry
register_shader(registry, name, shader_type, shader_id);
// Cleanup
free(line_copy);