diff options
| author | Ray <[email protected]> | 2020-09-14 19:20:38 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2020-09-14 19:20:38 +0200 |
| commit | 8cf0be4b6ce3a3cd04bdbc44ecfa3c2a304a891a (patch) | |
| tree | 9baed33adb1091a21c455d8aca9937382c744937 /src | |
| parent | 50736199620240c00e36a9168cde0b1ff47c5034 (diff) | |
| download | raylib-8cf0be4b6ce3a3cd04bdbc44ecfa3c2a304a891a.tar.gz raylib-8cf0be4b6ce3a3cd04bdbc44ecfa3c2a304a891a.zip | |
Review memory loading functions signesness
Diffstat (limited to 'src')
| -rw-r--r-- | src/raudio.c | 20 | ||||
| -rw-r--r-- | src/raylib.h | 17 | ||||
| -rw-r--r-- | src/text.c | 6 | ||||
| -rw-r--r-- | src/textures.c | 30 |
4 files changed, 37 insertions, 36 deletions
diff --git a/src/raudio.c b/src/raudio.c index 9e7c61f0..b18a9383 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -370,17 +370,17 @@ static void InitAudioBufferPool(void); // Initialise the multic static void CloseAudioBufferPool(void); // Close the audio buffers pool #if defined(SUPPORT_FILEFORMAT_WAV) -static Wave LoadWAV(const char *fileData, unsigned int fileSize); // Load WAV file +static Wave LoadWAV(const unsigned char *fileData, unsigned int fileSize); // Load WAV file static int SaveWAV(Wave wave, const char *fileName); // Save wave data as WAV file #endif #if defined(SUPPORT_FILEFORMAT_OGG) -static Wave LoadOGG(const char *fileData, unsigned int fileSize); // Load OGG file +static Wave LoadOGG(const unsigned char *fileData, unsigned int fileSize); // Load OGG file #endif #if defined(SUPPORT_FILEFORMAT_FLAC) -static Wave LoadFLAC(const char *fileData, unsigned int fileSize); // Load FLAC file +static Wave LoadFLAC(const unsigned char *fileData, unsigned int fileSize); // Load FLAC file #endif #if defined(SUPPORT_FILEFORMAT_MP3) -static Wave LoadMP3(const char *fileData, unsigned int fileSize); // Load MP3 file +static Wave LoadMP3(const unsigned char *fileData, unsigned int fileSize); // Load MP3 file #endif #if defined(RAUDIO_STANDALONE) @@ -695,7 +695,7 @@ Wave LoadWave(const char *fileName) unsigned char *fileData = LoadFileData(fileName, &fileSize); // Loading wave from memory data - wave = LoadWaveFromMemory(GetFileExtension(fileName), (char *)fileData, fileSize); + wave = LoadWaveFromMemory(GetFileExtension(fileName), fileData, fileSize); RL_FREE(fileData); @@ -703,7 +703,7 @@ Wave LoadWave(const char *fileName) } // Load wave from memory buffer, fileType refers to extension: i.e. "wav" -Wave LoadWaveFromMemory(const char *fileType, const char *fileData, int dataSize) +Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize) { Wave wave = { 0 }; @@ -1911,7 +1911,7 @@ static void CloseAudioBufferPool(void) #if defined(SUPPORT_FILEFORMAT_WAV) // Load WAV file data into Wave structure // NOTE: Using dr_wav library -static Wave LoadWAV(const char *fileData, unsigned int fileSize) +static Wave LoadWAV(const unsigned char *fileData, unsigned int fileSize) { Wave wave = { 0 }; drwav wav = { 0 }; @@ -1962,7 +1962,7 @@ static int SaveWAV(Wave wave, const char *fileName) #if defined(SUPPORT_FILEFORMAT_OGG) // Load OGG file data into Wave structure // NOTE: Using stb_vorbis library -static Wave LoadOGG(const char *fileData, unsigned int fileSize) +static Wave LoadOGG(const unsigned char *fileData, unsigned int fileSize) { Wave wave = { 0 }; @@ -1997,7 +1997,7 @@ static Wave LoadOGG(const char *fileData, unsigned int fileSize) #if defined(SUPPORT_FILEFORMAT_FLAC) // Load FLAC file data into Wave structure // NOTE: Using dr_flac library -static Wave LoadFLAC(const char *fileData, unsigned int fileSize) +static Wave LoadFLAC(const unsigned char *fileData, unsigned int fileSize) { Wave wave = { 0 }; @@ -2021,7 +2021,7 @@ static Wave LoadFLAC(const char *fileData, unsigned int fileSize) #if defined(SUPPORT_FILEFORMAT_MP3) // Load MP3 file data into Wave structure // NOTE: Using dr_mp3 library -static Wave LoadMP3(const char *fileData, unsigned int fileSize) +static Wave LoadMP3(const unsigned char *fileData, unsigned int fileSize) { Wave wave = { 0 }; drmp3_config config = { 0 }; diff --git a/src/raylib.h b/src/raylib.h index 4be53fd1..5c2ae13c 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -153,10 +153,11 @@ // Temporal hack to avoid breaking old codebases using // deprecated raylib implementation of these functions -#define FormatText TextFormat -#define SubText TextSubtext -#define ShowWindow UnhideWindow -#define LoadText LoadFileText +#define FormatText TextFormat +#define SubText TextSubtext +#define ShowWindow UnhideWindow +#define LoadText LoadFileText +#define GetExtension GetFileExtension //#define Fade(c, a) ColorAlpha(c, a) //---------------------------------------------------------------------------------- @@ -1103,7 +1104,7 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) -RLAPI Image LoadImageFromMemory(const char *fileType, const char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. "png" +RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. "png" RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM) RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file RLAPI void ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes @@ -1219,8 +1220,8 @@ RLAPI Font GetFontDefault(void); RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM) RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style) -RLAPI Font LoadFontFromMemory(const char *fileType, const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. "ttf" -RLAPI CharInfo *LoadFontData(const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use +RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. "ttf" +RLAPI CharInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use RLAPI Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM) @@ -1415,7 +1416,7 @@ RLAPI void SetMasterVolume(float volume); // Set mas // Wave/Sound loading/unloading functions RLAPI Wave LoadWave(const char *fileName); // Load wave data from file -RLAPI Wave LoadWaveFromMemory(const char *fileType, const char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. "wav" +RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. "wav" RLAPI Sound LoadSound(const char *fileName); // Load sound from file RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data @@ -341,7 +341,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou unsigned char *fileData = LoadFileData(fileName, &fileSize); // Loading font from memory data - font = LoadFontFromMemory(GetFileExtension(fileName), (char *)fileData, fileSize, fontSize, fontChars, charsCount); + font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, charsCount); RL_FREE(fileData); @@ -471,7 +471,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) } // Load font from memory buffer, fileType refers to extension: i.e. "ttf" -Font LoadFontFromMemory(const char *fileType, const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount) +Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount) { Font font = { 0 }; @@ -511,7 +511,7 @@ Font LoadFontFromMemory(const char *fileType, const char *fileData, int dataSize // Load font data for further use // NOTE: Requires TTF font memory data and can generate SDF data -CharInfo *LoadFontData(const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type) +CharInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type) { // NOTE: Using some SDF generation default values, // trades off precision with ability to handle *smaller* sizes diff --git a/src/textures.c b/src/textures.c index 2ffd804c..e375b263 100644 --- a/src/textures.c +++ b/src/textures.c @@ -171,20 +171,20 @@ // Module specific Functions Declaration //---------------------------------------------------------------------------------- #if defined(SUPPORT_FILEFORMAT_DDS) -static Image LoadDDS(const char *fileData, unsigned int fileSize); // Load DDS file data +static Image LoadDDS(const unsigned char *fileData, unsigned int fileSize); // Load DDS file data #endif #if defined(SUPPORT_FILEFORMAT_PKM) -static Image LoadPKM(const char *fileData, unsigned int fileSize); // Load PKM file data +static Image LoadPKM(const unsigned char *fileData, unsigned int fileSize); // Load PKM file data #endif #if defined(SUPPORT_FILEFORMAT_KTX) -static Image LoadKTX(const char *fileData, unsigned int fileSize); // Load KTX file data +static Image LoadKTX(const unsigned char *fileData, unsigned int fileSize); // Load KTX file data static int SaveKTX(Image image, const char *fileName); // Save image data as KTX file #endif #if defined(SUPPORT_FILEFORMAT_PVR) -static Image LoadPVR(const char *fileData, unsigned int fileSize); // Load PVR file data +static Image LoadPVR(const unsigned char *fileData, unsigned int fileSize); // Load PVR file data #endif #if defined(SUPPORT_FILEFORMAT_ASTC) -static Image LoadASTC(const char *fileData, unsigned int fileSize); // Load ASTC file data +static Image LoadASTC(const unsigned char *fileData, unsigned int fileSize); // Load ASTC file data #endif //---------------------------------------------------------------------------------- @@ -212,7 +212,7 @@ Image LoadImage(const char *fileName) unsigned char *fileData = LoadFileData(fileName, &fileSize); // Loading image from memory data - image = LoadImageFromMemory(GetFileExtension(fileName), (char *)fileData, fileSize); + image = LoadImageFromMemory(GetFileExtension(fileName), fileData, fileSize); if (image.data != NULL) TRACELOG(LOG_INFO, "IMAGE: [%s] Data loaded successfully (%ix%i)", fileName, image.width, image.height); else TRACELOG(LOG_WARNING, "IMAGE: [%s] Failed to load data", fileName); @@ -291,7 +291,7 @@ Image LoadImageAnim(const char *fileName, int *frames) } // Load image from memory buffer, fileType refers to extension: i.e. "png" -Image LoadImageFromMemory(const char *fileType, const char *fileData, int dataSize) +Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize) { Image image = { 0 }; @@ -330,7 +330,7 @@ Image LoadImageFromMemory(const char *fileType, const char *fileData, int dataSi if (fileData != NULL) { int comp = 0; - image.data = stbi_load_from_memory((unsigned char *)fileData, dataSize, &image.width, &image.height, &comp, 0); + image.data = stbi_load_from_memory(fileData, dataSize, &image.width, &image.height, &comp, 0); image.mipmaps = 1; @@ -348,7 +348,7 @@ Image LoadImageFromMemory(const char *fileType, const char *fileData, int dataSi if (fileData != NULL) { int comp = 0; - image.data = stbi_loadf_from_memory((unsigned char *)fileData, dataSize, &image.width, &image.height, &comp, 0); + image.data = stbi_loadf_from_memory(fileData, dataSize, &image.width, &image.height, &comp, 0); image.mipmaps = 1; @@ -3730,7 +3730,7 @@ int GetPixelDataSize(int width, int height, int format) //---------------------------------------------------------------------------------- #if defined(SUPPORT_FILEFORMAT_DDS) // Loading DDS image data (compressed or uncompressed) -static Image LoadDDS(const char *fileData, unsigned int fileSize) +static Image LoadDDS(const unsigned char *fileData, unsigned int fileSize) { unsigned char *fileDataPtr = (unsigned char *)fileData; @@ -3926,9 +3926,9 @@ static Image LoadDDS(const char *fileData, unsigned int fileSize) // Loading PKM image data (ETC1/ETC2 compression) // NOTE: KTX is the standard Khronos Group compression format (ETC1/ETC2, mipmaps) // PKM is a much simpler file format used mainly to contain a single ETC1/ETC2 compressed image (no mipmaps) -static Image LoadPKM(const char *fileData, unsigned int fileSize) +static Image LoadPKM(const unsigned char *fileData, unsigned int fileSize) { - unsigned char *fileDataPtr = fileData; + unsigned char *fileDataPtr = (unsigned char *)fileData; // Required extensions: // GL_OES_compressed_ETC1_RGB8_texture (ETC1) (OpenGL ES 2.0) @@ -4006,7 +4006,7 @@ static Image LoadPKM(const char *fileData, unsigned int fileSize) #if defined(SUPPORT_FILEFORMAT_KTX) // Load KTX compressed image data (ETC1/ETC2 compression) -static Image LoadKTX(const char *fileData, unsigned int fileSize) +static Image LoadKTX(const unsigned char *fileData, unsigned int fileSize) { unsigned char *fileDataPtr = (unsigned char *)fileData; @@ -4190,7 +4190,7 @@ static int SaveKTX(Image image, const char *fileName) #if defined(SUPPORT_FILEFORMAT_PVR) // Loading PVR image data (uncompressed or PVRT compression) // NOTE: PVR v2 not supported, use PVR v3 instead -static Image LoadPVR(const char *fileData, unsigned int fileSize) +static Image LoadPVR(const unsigned char *fileData, unsigned int fileSize) { unsigned char *fileDataPtr = (unsigned char *)fileData; @@ -4325,7 +4325,7 @@ static Image LoadPVR(const char *fileData, unsigned int fileSize) #if defined(SUPPORT_FILEFORMAT_ASTC) // Load ASTC compressed image data (ASTC compression) -static Image LoadASTC(const char *fileData, unsigned int fileSize) +static Image LoadASTC(const unsigned char *fileData, unsigned int fileSize) { unsigned char *fileDataPtr = (unsigned char *)fileData; |
