Ver código fonte

Some code tweaks for consistency

pull/1782/head
Ray 3 anos atrás
pai
commit
03710c9d8e
6 arquivos alterados com 24 adições e 24 exclusões
  1. +6
    -6
      src/core.c
  2. +11
    -11
      src/models.c
  3. +3
    -3
      src/raylib.h
  4. +2
    -2
      src/rlgl.h
  5. +1
    -1
      src/text.c
  6. +1
    -1
      src/utils.c

+ 6
- 6
src/core.c Ver arquivo

@ -2179,8 +2179,8 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
shader.id = rlLoadShaderCode(vShaderStr, fShaderStr);
if (vShaderStr != NULL) RL_FREE(vShaderStr);
if (fShaderStr != NULL) RL_FREE(fShaderStr);
if (vShaderStr != NULL) UnloadFileText(vShaderStr);
if (fShaderStr != NULL) UnloadFileText(fShaderStr);
// After shader loading, we TRY to set default location names
if (shader.id > 0)
@ -2801,8 +2801,8 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount)
ClearDirectoryFiles();
// Memory allocation for MAX_DIRECTORY_FILES
dirFilesPath = (char **)RL_MALLOC(sizeof(char *)*MAX_DIRECTORY_FILES);
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH);
dirFilesPath = (char **)RL_MALLOC(n">MAX_DIRECTORY_FILES*sizeof(char *));
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(n">MAX_FILEPATH_LENGTH*sizeof(char));
int counter = 0;
struct dirent *entity;
@ -5151,11 +5151,11 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
{
ClearDroppedFiles();
CORE.Window.dropFilesPath = (char **)RL_MALLOC(sizeof(char *)*count);
CORE.Window.dropFilesPath = (char **)RL_MALLOC(n">count*sizeof(char *));
for (int i = 0; i < count; i++)
{
CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH);
CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(n">MAX_FILEPATH_LENGTH*sizeof(char));
strcpy(CORE.Window.dropFilesPath[i], paths[i]);
}

+ 11
- 11
src/models.c Ver arquivo

@ -3205,11 +3205,11 @@ static Model LoadOBJ(const char *fileName)
tinyobj_material_t *materials = NULL;
unsigned int materialCount = 0;
char *fileData = LoadFileText(fileName);
char *fileText = LoadFileText(fileName);
if (fileData != NULL)
if (fileText != NULL)
{
unsigned int dataSize = (unsigned int)strlen(fileData);
unsigned int dataSize = (unsigned int)strlen(fileText);
char currentDir[1024] = { 0 };
strcpy(currentDir, GetWorkingDirectory());
const char *workingDir = GetDirectoryPath(fileName);
@ -3219,7 +3219,7 @@ static Model LoadOBJ(const char *fileName)
}
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, fileData, dataSize, flags);
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, fileText, dataSize, flags);
if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load OBJ data", fileName);
else TRACELOG(LOG_INFO, "MODEL: [%s] OBJ data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);
@ -3346,9 +3346,9 @@ static Model LoadOBJ(const char *fileName)
tinyobj_shapes_free(meshes, meshCount);
tinyobj_materials_free(materials, materialCount);
RL_FREE(fileData);
UnloadFileText(fileText);
RL_FREE(matFaces);
RL_FREE(vCount);
RL_FREE(vtCount);
RL_FREE(vnCount);
@ -3496,7 +3496,7 @@ static Model LoadIQM(const char *fileName)
//fileDataPtr += sizeof(IQMHeader); // Move file data pointer
// Meshes data processing
imesh = RL_MALLOC(k">sizeof(IQMMesh)*iqmHeader->num_meshes);
imesh = RL_MALLOC(n">iqmHeader->num_meshes*sizeof(IQMMesh));
//fseek(iqmFile, iqmHeader->ofs_meshes, SEEK_SET);
//fread(imesh, sizeof(IQMMesh)*iqmHeader->num_meshes, 1, iqmFile);
memcpy(imesh, fileDataPtr + iqmHeader->ofs_meshes, iqmHeader->num_meshes*sizeof(IQMMesh));
@ -4466,8 +4466,8 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
{
if (jointsAccessor->component_type == cgltf_component_type_r_16u)
{
model->meshes[primitiveIndex].boneIds = RL_MALLOC(k">sizeof(int)*jointsAccessor->count*4);
short* bones = RL_MALLOC(k">sizeof(short)*jointsAccessor->count*4);
model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int));
short* bones = RL_MALLOC(jointsAccessor->count*4*sizeof(short));
for (unsigned int a = 0; a < jointsAccessor->count; a++)
{
@ -4491,8 +4491,8 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
}
else if (jointsAccessor->component_type == cgltf_component_type_r_8u)
{
model->meshes[primitiveIndex].boneIds = RL_MALLOC(k">sizeof(int)*jointsAccessor->count*4);
unsigned char* bones = RL_MALLOC(k">sizeof(unsigned char)*jointsAccessor->count*4);
model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int));
unsigned char* bones = RL_MALLOC(n">jointsAccessor->count*4*sizeof(unsigned char));
for (unsigned int a = 0; a < jointsAccessor->count; a++)
{

+ 3
- 3
src/raylib.h Ver arquivo

@ -898,9 +898,9 @@ typedef enum {
// Callbacks to hook some internal functions
// WARNING: This callbacks are intended for advance users
typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages
typedef unsigned char* (*LoadFileDataCallback)(const char* fileName, unsigned int* bytesRead); // FileIO: Load binary data
typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data
typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
typedef char *(*LoadFileTextCallback)(const char* fileName); // FileIO: Load text data
typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data
typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data
@ -1040,7 +1040,7 @@ RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
RLAPI void UnloadFileText(unsigned char *text); // Unload file text data allocated by LoadFileText()
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
RLAPI bool FileExists(const char *fileName); // Check if file exists
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists

+ 2
- 2
src/rlgl.h Ver arquivo

@ -1685,7 +1685,7 @@ void rlLoadExtensions(void *loader)
#if defined(SUPPORT_GL_DETAILS_INFO)
// Get supported extensions list
// WARNING: glGetStringi() not available on OpenGL 2.1
char **extList = RL_MALLOC(sizeof(char *)*numExt);
char **extList = RL_MALLOC(n">numExt*sizeof(char *));
TRACELOG(LOG_INFO, "GL: OpenGL extensions:");
for (int i = 0; i < numExt; i++)
{
@ -1966,7 +1966,7 @@ RenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Initialize CPU (RAM) vertex buffers (position, texcoord, color data and indexes)
//--------------------------------------------------------------------------------------------
batch.vertexBuffer = (VertexBuffer *)RL_MALLOC(sizeof(VertexBuffer)*numBuffers);
batch.vertexBuffer = (VertexBuffer *)RL_MALLOC(n">numBuffers*sizeof(VertexBuffer));
for (int i = 0; i < numBuffers; i++)
{

+ 1
- 1
src/text.c Ver arquivo

@ -1865,7 +1865,7 @@ static Font LoadBMFont(const char *fileName)
}
UnloadImage(imFont);
RL_FREE(fileText);
UnloadFileText(fileText);
if (font.texture.id == 0)
{

+ 1
- 1
src/utils.c Ver arquivo

@ -325,7 +325,7 @@ char *LoadFileText(const char *fileName)
}
// Unload file text data allocated by LoadFileText()
void UnloadFileText(unsigned char *text)
void UnloadFileText(char *text)
{
RL_FREE(text);
}

Carregando…
Cancelar
Salvar