[cppcheck] Improvements in SaveStorageValue() in core.c (#1160)
* [cppcheck] Improvements in SaveStorageValue() in core.c in file core.c cppcheck shows errors only in function SaveStorageValue(): * Common realloc mistake: 'fileData' nulled but not freed upon failure * Memory pointed to by 'fileData' is freed twice. Validation: * Tested examples/core/core_storage_values.c * Launched Unit Test for this function * Rerun CPPCHECK afer fix * [cppcheck] Change functions header to accept only positive position in files Changes: * Functions SaveStorageValue(), LoadStorageValue() (core.c) * Functions LoadFileData(), SaveFileData() (utils.c) * Headers in raylib.h Validation: * Tested examples/core/core_storage_values.c * Launched Unit Test for these functions * Rerun CPPCHECK afer fix
This commit is contained in:
parent
9b66883e0b
commit
62cdb2299b
3 changed files with 42 additions and 20 deletions
|
@ -951,8 +951,8 @@ RLAPI void TakeScreenshot(const char *fileName); // Takes a scr
|
|||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
// Files management functions
|
||||
RLAPI unsigned char *LoadFileData(const char *fileName, int *bytesRead); // Load file data as byte array (read)
|
||||
RLAPI void SaveFileData(const char *fileName, void *data, int bytesToWrite); // Save data to file from byte array (write)
|
||||
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
|
||||
RLAPI void SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write)
|
||||
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
||||
RLAPI void SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated
|
||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||
|
@ -976,8 +976,8 @@ RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *comp
|
|||
RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm)
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void SaveStorageValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int LoadStorageValue(int position); // Load integer value from storage file (from defined position)
|
||||
RLAPI void SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int LoadStorageValue(unsigned int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue