fix various problems, thanks CppCheck :) (#1005)
* explained a bit more the core_window_letterbox example * fixed a few 'ups' moments that could lead to mild head pain and time loss
This commit is contained in:
parent
64c588e9d8
commit
75b0264f35
7 changed files with 37 additions and 10 deletions
|
@ -929,12 +929,16 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic);
|
TraceLog(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic);
|
||||||
fclose(iqmFile);
|
fclose(iqmFile);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iqm.version != IQM_VERSION)
|
if (iqm.version != IQM_VERSION)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
|
TraceLog(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
|
||||||
fclose(iqmFile);
|
fclose(iqmFile);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get bones data
|
// Get bones data
|
||||||
|
|
27
src/physac.h
27
src/physac.h
|
@ -842,9 +842,17 @@ PHYSACDEF void DestroyPhysicsBody(PhysicsBody body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PHYSAC_DEBUG)
|
|
||||||
if (index == -1) printf("[PHYSAC] cannot find body id %i in pointers array\n", id);
|
if (index == -1){
|
||||||
#endif
|
|
||||||
|
#if defined(PHYSAC_DEBUG)
|
||||||
|
printf("[PHYSAC] cannot find body id %i in pointers array\n", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// prevent access to index -1
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Free body allocated memory
|
// Free body allocated memory
|
||||||
PHYSAC_FREE(body);
|
PHYSAC_FREE(body);
|
||||||
|
@ -1249,9 +1257,16 @@ static void DestroyPhysicsManifold(PhysicsManifold manifold)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PHYSAC_DEBUG)
|
|
||||||
if (index == -1) printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id);
|
if (index == -1) {
|
||||||
#endif
|
#if defined(PHYSAC_DEBUG)
|
||||||
|
printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//prevent access to index -1
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Free manifold allocated memory
|
// Free manifold allocated memory
|
||||||
PHYSAC_FREE(manifold);
|
PHYSAC_FREE(manifold);
|
||||||
|
|
|
@ -592,13 +592,14 @@ void SetMasterVolume(float volume)
|
||||||
AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 bufferSizeInFrames, int usage)
|
AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 bufferSizeInFrames, int usage)
|
||||||
{
|
{
|
||||||
AudioBuffer *audioBuffer = (AudioBuffer *)RL_CALLOC(1, sizeof(AudioBuffer));
|
AudioBuffer *audioBuffer = (AudioBuffer *)RL_CALLOC(1, sizeof(AudioBuffer));
|
||||||
audioBuffer->buffer = RL_CALLOC(bufferSizeInFrames*channels*ma_get_bytes_per_sample(format), 1);
|
|
||||||
|
|
||||||
if (audioBuffer == NULL)
|
if (audioBuffer == NULL)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer");
|
TraceLog(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioBuffer->buffer = RL_CALLOC(bufferSizeInFrames*channels*ma_get_bytes_per_sample(format), 1);
|
||||||
|
|
||||||
// Audio data runs through a format converter
|
// Audio data runs through a format converter
|
||||||
ma_pcm_converter_config dspConfig;
|
ma_pcm_converter_config dspConfig;
|
||||||
|
|
|
@ -1887,6 +1887,13 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
|
||||||
#endif
|
#endif
|
||||||
#endif // GRAPHICS_API_OPENGL_11
|
#endif // GRAPHICS_API_OPENGL_11
|
||||||
|
|
||||||
|
if( data == NULL ){
|
||||||
|
//ups!
|
||||||
|
TraceLog(LOG_WARNING, "Got asked to load texture from a NULL pointer!");
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
glGenTextures(1, &id); // Generate texture id
|
glGenTextures(1, &id); // Generate texture id
|
||||||
|
|
|
@ -1524,7 +1524,7 @@ static float EaseCubicInOut(float t, float b, float c, float d)
|
||||||
// Get texture to draw shapes (RAII)
|
// Get texture to draw shapes (RAII)
|
||||||
static Texture2D GetShapesTexture(void)
|
static Texture2D GetShapesTexture(void)
|
||||||
{
|
{
|
||||||
if (texShapes.id <= 0)
|
if (texShapes.id == 0) //this variable is an unsigned int, will never be negative
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_FONT_TEXTURE)
|
#if defined(SUPPORT_FONT_TEXTURE)
|
||||||
texShapes = GetFontDefault().texture; // Use font texture white character
|
texShapes = GetFontDefault().texture; // Use font texture white character
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ char *TextToUtf8(int *codepoints, int length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize memory to text length + string NULL terminator
|
// Resize memory to text length + string NULL terminator
|
||||||
realloc(text, size + 1);
|
text = realloc(text, size + 1);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,7 +662,7 @@ Vector4 *GetImageDataNormalized(Image image)
|
||||||
pixels[i].w = 1.0f;
|
pixels[i].w = 1.0f;
|
||||||
|
|
||||||
k += 3;
|
k += 3;
|
||||||
}
|
} break;
|
||||||
case UNCOMPRESSED_R32G32B32A32:
|
case UNCOMPRESSED_R32G32B32A32:
|
||||||
{
|
{
|
||||||
pixels[i].x = ((float *)image.data)[k];
|
pixels[i].x = ((float *)image.data)[k];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue