Review all RL_CALLOC() calls
All data should be properly initialized by now
This commit is contained in:
parent
37a6f12037
commit
c661cad692
4 changed files with 21 additions and 22 deletions
30
src/models.c
30
src/models.c
|
@ -829,7 +829,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
|
|||
Material LoadMaterialDefault(void)
|
||||
{
|
||||
Material material = { 0 };
|
||||
material.maps = (MaterialMap *)RL_CALLOC(MAX_MATERIAL_MAPS*sizeof(MaterialMap), 1);
|
||||
material.maps = (MaterialMap *)RL_CALLOC(MAX_MATERIAL_MAPS, sizeof(MaterialMap));
|
||||
|
||||
material.shader = GetShaderDefault();
|
||||
material.maps[MAP_DIFFUSE].texture = GetTextureDefault(); // White texture (1x1 pixel)
|
||||
|
@ -1181,7 +1181,7 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim)
|
|||
Mesh GenMeshPoly(int sides, float radius)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
int vertexCount = sides*3;
|
||||
|
||||
// Vertices definition
|
||||
|
@ -1244,7 +1244,7 @@ Mesh GenMeshPoly(int sides, float radius)
|
|||
Mesh GenMeshPlane(float width, float length, int resX, int resZ)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
#define CUSTOM_MESH_GEN_PLANE
|
||||
#if defined(CUSTOM_MESH_GEN_PLANE)
|
||||
|
@ -1347,7 +1347,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ)
|
|||
mesh.vertices = (float *)RL_MALLOC(plane->ntriangles*3*3*sizeof(float));
|
||||
mesh.texcoords = (float *)RL_MALLOC(plane->ntriangles*3*2*sizeof(float));
|
||||
mesh.normals = (float *)RL_MALLOC(plane->ntriangles*3*3*sizeof(float));
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int));
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
mesh.vertexCount = plane->ntriangles*3;
|
||||
mesh.triangleCount = plane->ntriangles;
|
||||
|
@ -1379,7 +1379,7 @@ Mesh GenMeshPlane(float width, float length, int resX, int resZ)
|
|||
Mesh GenMeshCube(float width, float height, float length)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
#define CUSTOM_MESH_GEN_CUBE
|
||||
#if defined(CUSTOM_MESH_GEN_CUBE)
|
||||
|
@ -1545,7 +1545,7 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron
|
|||
RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
par_shapes_mesh *sphere = par_shapes_create_parametric_sphere(slices, rings);
|
||||
par_shapes_scale(sphere, radius, radius, radius);
|
||||
|
@ -1584,7 +1584,7 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
|
|||
RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
par_shapes_mesh *sphere = par_shapes_create_hemisphere(slices, rings);
|
||||
par_shapes_scale(sphere, radius, radius, radius);
|
||||
|
@ -1623,7 +1623,7 @@ RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices)
|
|||
Mesh GenMeshCylinder(float radius, float height, int slices)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
// Instance a cylinder that sits on the Z=0 plane using the given tessellation
|
||||
// levels across the UV domain. Think of "slices" like a number of pizza
|
||||
|
@ -1682,7 +1682,7 @@ Mesh GenMeshCylinder(float radius, float height, int slices)
|
|||
Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
if (radius > 1.0f) radius = 1.0f;
|
||||
else if (radius < 0.1f) radius = 0.1f;
|
||||
|
@ -1725,7 +1725,7 @@ Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
|
|||
Mesh GenMeshKnot(float radius, float size, int radSeg, int sides)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
if (radius > 3.0f) radius = 3.0f;
|
||||
else if (radius < 0.5f) radius = 0.5f;
|
||||
|
@ -1769,7 +1769,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
|
|||
#define GRAY_VALUE(c) ((c.r+c.g+c.b)/3)
|
||||
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
int mapX = heightmap.width;
|
||||
int mapZ = heightmap.height;
|
||||
|
@ -1878,7 +1878,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
|
|||
Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
Color *cubicmapPixels = GetImageData(cubicmap);
|
||||
|
||||
|
@ -2819,7 +2819,7 @@ static Model LoadOBJ(const char *fileName)
|
|||
mesh.vertices = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float));
|
||||
mesh.texcoords = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float));
|
||||
mesh.normals = (float *)RL_MALLOC(mesh.vertexCount*3*sizeof(float));
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
mesh.vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
int vCount = 0;
|
||||
int vtCount = 0;
|
||||
|
@ -3089,7 +3089,7 @@ static Model LoadIQM(const char *fileName)
|
|||
model.meshes[i].animVertices = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3);
|
||||
model.meshes[i].animNormals = RL_MALLOC(sizeof(float)*model.meshes[i].vertexCount*3);
|
||||
|
||||
model.meshes[i].vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
model.meshes[i].vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
}
|
||||
|
||||
// Triangles data processing
|
||||
|
@ -3411,7 +3411,7 @@ static Model LoadGLTF(const char *fileName)
|
|||
model.materials = RL_MALLOC(model.materialCount*sizeof(Material));
|
||||
model.meshMaterial = RL_MALLOC(model.meshCount*sizeof(int));
|
||||
|
||||
for (int i = 0; i < model.meshCount; i++) model.meshes[i].vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO*sizeof(unsigned int), 1);
|
||||
for (int i = 0; i < model.meshCount; i++) model.meshes[i].vboId = (unsigned int *)RL_CALLOC(MAX_MESH_VBO, sizeof(unsigned int));
|
||||
|
||||
for (int i = 0; i < model.materialCount - 1; i++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue