Fixed some errors pointed out by valgrind

dev
shariq 8 years ago
parent ff51f3f990
commit 5c5ac44b98
  1. 10
      src/file_io.c
  2. 8
      src/game.c
  3. 2
      src/hashmap.c

@ -25,15 +25,15 @@ char* io_file_read(const char* path, const char* mode, long* file_size)
int rc = fseek(file, 0, SEEK_END);
if(rc == 0)
{
long size = (size_t)ftell(file);
if(file_size) *file_size = size;
long length = (size_t)ftell(file);
if(file_size) *file_size = length;
rewind(file);
data = malloc(sizeof(char) * size + 1);
data = calloc(1, (sizeof(char) * length) + 1);
if(data)
{
if(fread(data, size, 1, file) > 0)
if(fread(data, length, 1, file) > 0)
{
if(data[size] != '\0') data[size] = '\0';
if(data[length] != '\0') data[length] = '\0';
}
else
{

@ -36,7 +36,7 @@
#define LEN(a) (sizeof(a)/sizeof(a)[0])
#define MAX_FRAME_TIME 1.f
#define MAX_FRAME_TIME 0.5f
static void run(void);
static void update(float dt, int* window_should_close);
@ -131,7 +131,7 @@ void scene_setup(void)
struct Transform* tran = entity_component_get(new_ent, C_TRANSFORM);
vec3 position = {0, 0, -5};
transform_translate(tran, &position, TS_WORLD);
struct Model* box_model = entity_component_add(new_ent, C_MODEL, "torus.pamesh", "Blinn_Phong");
struct Model* box_model = entity_component_add(new_ent, C_MODEL, "default.pamesh", "Blinn_Phong");
model_set_material_param(box_model, "diffuse_color", &color);
int tex = texture_create_from_file("white.tga", TU_DIFFUSE);
model_set_material_param(box_model, "diffuse_texture", &tex);
@ -149,7 +149,7 @@ void scene_setup(void)
}
int parent_node = new_ent->node;
int num_suz = 100;
int num_suz = 1;
srand(time(NULL));
for(int i = 0; i < num_suz; i++)
{
@ -159,7 +159,7 @@ void scene_setup(void)
x++; y++; z++;
struct Entity* suz = scene_add_as_child("Suzanne", NULL, parent_node);
//struct Entity* suz = scene_add_new("Suzanne", NULL);
struct Model* suz_model = entity_component_add(suz, C_MODEL, "suzanne.pamesh", "Blinn_Phong");
struct Model* suz_model = entity_component_add(suz, C_MODEL, "default.pamesh", "Blinn_Phong");
model_set_material_param(suz_model, "diffuse_color", &color);
float spec_str = 80.f;
model_set_material_param(suz_model, "specular_strength", &spec_str);

@ -39,6 +39,8 @@ static struct Hashmap_Entry* hashmap_entry_new(struct Hashmap* hashmap, const ch
}
if(!new_entry) new_entry = array_grow(hashmap->buckets[index], struct Hashmap_Entry);
new_entry->key = str_new(key);
new_entry->value.type = VT_NONE;
variant_free(&new_entry->value);
return new_entry;
}

Loading…
Cancel
Save