summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2020-12-14 20:47:58 +0100
committerRay <[email protected]>2020-12-14 20:47:58 +0100
commitd360a49f3608af328dc402516ee444e1d1d6902a (patch)
tree4fe4a05864ba99eb39dfee8993e7fcc7188da56b /src
parentcd3eb3d8bd93fce7c6604b1ed06ef1b1fcd25340 (diff)
downloadraylib-d360a49f3608af328dc402516ee444e1d1d6902a.tar.gz
raylib-d360a49f3608af328dc402516ee444e1d1d6902a.zip
ADDED: UnloadFileData() / UnloadFileText() #1440
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h2
-rw-r--r--src/utils.c12
2 files changed, 14 insertions, 0 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 4d889e34..27461494 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -974,8 +974,10 @@ RLAPI int GetRandomValue(int min, int max); // Returns a r
// Files management functions
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
+RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
+RLAPI void UnloadFileText(unsigned char *text); // Unload file text data allocated by LoadFileText()
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
RLAPI bool FileExists(const char *fileName); // Check if file exists
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
diff --git a/src/utils.c b/src/utils.c
index 6595b09f..ca133ca1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -203,6 +203,12 @@ unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
return data;
}
+// Unload file data allocated by LoadFileData()
+void UnloadFileData(unsigned char *data)
+{
+ RL_FREE(data);
+}
+
// Save data to file from buffer
bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite)
{
@@ -274,6 +280,12 @@ char *LoadFileText(const char *fileName)
return text;
}
+// Unload file text data allocated by LoadFileText()
+void UnloadFileText(unsigned char *text)
+{
+ RL_FREE(text);
+}
+
// Save text data to file (write), string must be '\0' terminated
bool SaveFileText(const char *fileName, char *text)
{