Skip to content

Commit fc5894e

Browse files
committed
REVIEWED: Some compilation warnings (for strict rules)
1 parent 2fd6d7e commit fc5894e

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/rcore.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,17 +2755,19 @@ float GetFrameTime(void)
27552755
// NOTE: On PLATFORM_DESKTOP, timer is initialized on glfwInit()
27562756
double GetTime(void)
27572757
{
2758+
double time = 0.0;
27582759
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
2759-
return glfwGetTime(); // Elapsed time since glfwInit()
2760+
time = glfwGetTime(); // Elapsed time since glfwInit()
27602761
#endif
27612762

27622763
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
27632764
struct timespec ts = { 0 };
27642765
clock_gettime(CLOCK_MONOTONIC, &ts);
27652766
unsigned long long int time = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
27662767

2767-
return (double)(time - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
2768+
time = (double)(time - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
27682769
#endif
2770+
return time;
27692771
}
27702772

27712773
// Setup window configuration flags (view FLAGS)
@@ -3291,12 +3293,12 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
32913293

32923294
#if defined(SUPPORT_COMPRESSION_API)
32933295
// Decompress data from a valid DEFLATE stream
3294-
data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
3296+
data = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
32953297
int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
32963298

32973299
// WARNING: RL_REALLOC can make (and leave) data copies in memory, be careful with sensitive compressed data!
32983300
// TODO: Use a different approach, create another buffer, copy data manually to it and wipe original buffer memory
3299-
unsigned char *temp = RL_REALLOC(data, length);
3301+
unsigned char *temp = (unsigned char *)RL_REALLOC(data, length);
33003302

33013303
if (temp != NULL) data = temp;
33023304
else TRACELOG(LOG_WARNING, "SYSTEM: Failed to re-allocate required decompression memory");
@@ -3322,7 +3324,7 @@ char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize)
33223324

33233325
*outputSize = 4*((dataSize + 2)/3);
33243326

3325-
char *encodedData = RL_MALLOC(*outputSize);
3327+
char *encodedData = (char *)RL_MALLOC(*outputSize);
33263328

33273329
if (encodedData == NULL) return NULL;
33283330

src/rtext.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ extern void LoadFontDefault(void)
199199
// Re-construct image from defaultFontData and generate OpenGL texture
200200
//----------------------------------------------------------------------
201201
Image imFont = {
202-
.data = calloc(128*128, 2), // 2 bytes per pixel (gray + alpha)
202+
.data = RL_CALLOC(128*128, 2), // 2 bytes per pixel (gray + alpha)
203203
.width = 128,
204204
.height = 128,
205-
.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
206-
.mipmaps = 1
205+
.mipmaps = 1,
206+
.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
207207
};
208208

209209
// Fill image.data with defaultFontData (convert from bit to pixel!)
@@ -454,8 +454,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
454454
.data = pixels,
455455
.width = image.width,
456456
.height = image.height,
457-
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
458-
.mipmaps = 1
457+
.mipmaps = 1,
458+
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
459459
};
460460

461461
// Set font with all data parsed from image
@@ -620,11 +620,11 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
620620
if (ch == 32)
621621
{
622622
Image imSpace = {
623-
.data = calloc(chars[i].advanceX*fontSize, 2),
623+
.data = RL_CALLOC(chars[i].advanceX*fontSize, 2),
624624
.width = chars[i].advanceX,
625625
.height = fontSize,
626-
.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE,
627-
.mipmaps = 1
626+
.mipmaps = 1,
627+
.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
628628
};
629629

630630
chars[i].image = imSpace;
@@ -896,7 +896,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
896896

897897
// Compress font image data
898898
int compDataSize = 0;
899-
unsigned char *compData = CompressData(image.data, imageDataSize, &compDataSize);
899+
unsigned char *compData = CompressData((const unsigned char *)image.data, imageDataSize, &compDataSize);
900900

901901
// Save font image data (compressed)
902902
byteCount += sprintf(txtData + byteCount, "#define COMPRESSED_DATA_SIZE_FONT_%s %i\n\n", TextToUpper(fileNamePascal), compDataSize);
@@ -1665,7 +1665,7 @@ int *LoadCodepoints(const char *text, int *count)
16651665
int codepointCount = 0;
16661666

16671667
// Allocate a big enough buffer to store as many codepoints as text bytes
1668-
int *codepoints = RL_CALLOC(textLength, sizeof(int));
1668+
int *codepoints = (int *)RL_CALLOC(textLength, sizeof(int));
16691669

16701670
for (int i = 0; i < textLength; codepointCount++)
16711671
{
@@ -1674,7 +1674,7 @@ int *LoadCodepoints(const char *text, int *count)
16741674
}
16751675

16761676
// Re-allocate buffer to the actual number of codepoints loaded
1677-
void *temp = RL_REALLOC(codepoints, codepointCount*sizeof(int));
1677+
int *temp = (int *)RL_REALLOC(codepoints, codepointCount*sizeof(int));
16781678
if (temp != NULL) codepoints = temp;
16791679

16801680
*count = codepointCount;
@@ -1992,7 +1992,7 @@ static Font LoadBMFont(const char *fileName)
19921992
if (lastSlash != NULL)
19931993
{
19941994
// NOTE: We need some extra space to avoid memory corruption on next allocations!
1995-
imPath = RL_CALLOC(TextLength(fileName) - TextLength(lastSlash) + TextLength(imFileName) + 4, 1);
1995+
imPath = (char *)RL_CALLOC(TextLength(fileName) - TextLength(lastSlash) + TextLength(imFileName) + 4, 1);
19961996
memcpy(imPath, fileName, TextLength(fileName) - TextLength(lastSlash) + 1);
19971997
memcpy(imPath + TextLength(fileName) - TextLength(lastSlash) + 1, imFileName, TextLength(imFileName));
19981998
}
@@ -2006,11 +2006,11 @@ static Font LoadBMFont(const char *fileName)
20062006
{
20072007
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
20082008
Image imFontAlpha = {
2009-
.data = calloc(imFont.width*imFont.height, 2),
2009+
.data = RL_CALLOC(imFont.width*imFont.height, 2),
20102010
.width = imFont.width,
20112011
.height = imFont.height,
2012-
.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
2013-
.mipmaps = 1
2012+
.mipmaps = 1,
2013+
.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
20142014
};
20152015

20162016
for (int p = 0, i = 0; p < (imFont.width*imFont.height*2); p += 2, i++)

0 commit comments

Comments
 (0)