Some code tweaks

This commit is contained in:
Ray 2021-05-30 11:50:32 +02:00
parent c828e481fb
commit 0369ec9adf
4 changed files with 10 additions and 10 deletions

View file

@ -1027,7 +1027,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins
if (instancing) if (instancing)
{ {
// Create instances buffer // Create instances buffer
instanceTransforms = RL_MALLOC(instances*sizeof(float16)); instanceTransforms = (float16 *)RL_MALLOC(instances*sizeof(float16));
// Fill buffer with instances transformations as float16 arrays // Fill buffer with instances transformations as float16 arrays
for (int i = 0; i < instances; i++) instanceTransforms[i] = MatrixToFloatV(transforms[i]); for (int i = 0; i < instances; i++) instanceTransforms[i] = MatrixToFloatV(transforms[i]);

View file

@ -1428,13 +1428,13 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
#if defined(SUPPORT_FILEFORMAT_MOD) #if defined(SUPPORT_FILEFORMAT_MOD)
else if (TextIsEqual(fileExtLower, ".mod")) else if (TextIsEqual(fileExtLower, ".mod"))
{ {
jar_mod_context_t *ctxMod = RL_MALLOC(sizeof(jar_mod_context_t)); jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_MALLOC(sizeof(jar_mod_context_t));
int result = 0; int result = 0;
jar_mod_init(ctxMod); jar_mod_init(ctxMod);
// copy data to allocated memory for default UnloadMusicStream // Copy data to allocated memory for default UnloadMusicStream
unsigned char *newData = RL_MALLOC(dataSize); unsigned char *newData = (unsigned char *)RL_MALLOC(dataSize);
int it = dataSize/sizeof(unsigned char); int it = dataSize/sizeof(unsigned char);
for (int i = 0; i < it; i++){ for (int i = 0; i < it; i++){
newData[i] = data[i]; newData[i] = data[i];

View file

@ -1272,7 +1272,7 @@ const char *TextSubtext(const char *text, int position, int length)
// Replace text string // Replace text string
// REQUIRES: strstr(), strncpy(), strcpy() // REQUIRES: strstr(), strncpy(), strcpy()
// WARNING: Internally allocated memory must be freed by the user (if return != NULL) // WARNING: Returned buffer must be freed by the user (if return != NULL)
char *TextReplace(char *text, const char *replace, const char *by) char *TextReplace(char *text, const char *replace, const char *by)
{ {
// Sanity checks and initialization // Sanity checks and initialization
@ -1297,14 +1297,14 @@ char *TextReplace(char *text, const char *replace, const char *by)
for (count = 0; (temp = strstr(insertPoint, replace)); count++) insertPoint = temp + replaceLen; for (count = 0; (temp = strstr(insertPoint, replace)); count++) insertPoint = temp + replaceLen;
// Allocate returning string and point temp to it // Allocate returning string and point temp to it
temp = result = RL_MALLOC(TextLength(text) + (byLen - replaceLen)*count + 1); temp = result = (char *)RL_MALLOC(TextLength(text) + (byLen - replaceLen)*count + 1);
if (!result) return NULL; // Memory could not be allocated if (!result) return NULL; // Memory could not be allocated
// First time through the loop, all the variable are set correctly from here on, // First time through the loop, all the variable are set correctly from here on,
// temp points to the end of the result string // - 'temp' points to the end of the result string
// insertPoint points to the next occurrence of replace in text // - 'insertPoint' points to the next occurrence of replace in text
// text points to the remainder of text after "end of replace" // - 'text' points to the remainder of text after "end of replace"
while (count--) while (count--)
{ {
insertPoint = strstr(text, replace); insertPoint = strstr(text, replace);

View file

@ -1354,7 +1354,7 @@ void ImageResize(Image *image, int newWidth, int newHeight)
if (fastPath) if (fastPath)
{ {
int bytesPerPixel = GetPixelDataSize(1, 1, image->format); int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
unsigned char *output = RL_MALLOC(newWidth*newHeight*bytesPerPixel); unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);
switch (image->format) switch (image->format)
{ {