summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2022-04-06 20:50:50 +0200
committerRay <[email protected]>2022-04-06 20:50:50 +0200
commitf71cc53bc99e7efbf00ffd9147fc4c029fcc6f7d (patch)
treeaa0c4498c76e5b03669c34a392c120125399313b
parent07240b96ad7c689119e70714f3fb39852b3657b7 (diff)
downloadraylib-f71cc53bc99e7efbf00ffd9147fc4c029fcc6f7d.tar.gz
raylib-f71cc53bc99e7efbf00ffd9147fc4c029fcc6f7d.zip
WARNING: RENAMED: some parameters from length to size
When referring to byte array SIZE, I find it more clear than length
-rw-r--r--src/raylib.h8
-rw-r--r--src/rcore.c62
2 files changed, 35 insertions, 35 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 7cb19927..b6f77d87 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1063,10 +1063,10 @@ RLAPI void ClearDroppedFiles(void); // Clear dropp
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
// Compression/Encoding functionality
-RLAPI unsigned char *CompressData(const unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm)
-RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm)
-RLAPI char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength); // Encode data to Base64 string
-RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength); // Decode Base64 string data
+RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm)
+RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm)
+RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string
+RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data
// Persistent storage management
RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success
diff --git a/src/rcore.c b/src/rcore.c
index d4b10504..12e68db3 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -3187,7 +3187,7 @@ long GetFileModTime(const char *fileName)
}
// Compress data (DEFLATE algorythm)
-unsigned char *CompressData(const unsigned char *data, int dataLength, int *compDataLength)
+unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize)
{
#define COMPRESSION_QUALITY_DEFLATE 8
@@ -3196,40 +3196,40 @@ unsigned char *CompressData(const unsigned char *data, int dataLength, int *comp
#if defined(SUPPORT_COMPRESSION_API)
// Compress data and generate a valid DEFLATE stream
struct sdefl sdefl = { 0 };
- int bounds = sdefl_bound(dataLength);
+ int bounds = sdefl_bound(dataSize);
compData = (unsigned char *)RL_CALLOC(bounds, 1);
- *compDataLength = sdeflate(&sdefl, compData, data, dataLength, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbwi
+ *compDataSize = sdeflate(&sdefl, compData, data, dataSize, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbwi
- TraceLog(LOG_INFO, "SYSTEM: Compress data: Original size: %i -> Comp. size: %i", dataLength, *compDataLength);
+ TraceLog(LOG_INFO, "SYSTEM: Compress data: Original size: %i -> Comp. size: %i", dataSize, *compDataSize);
#endif
return compData;
}
// Decompress data (DEFLATE algorythm)
-unsigned char *DecompressData(const unsigned char *compData, int compDataLength, int *dataLength)
+unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize)
{
unsigned char *data = NULL;
#if defined(SUPPORT_COMPRESSION_API)
// Decompress data from a valid DEFLATE stream
data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
- int length = sinflate(data, MAX_DECOMPRESSION_SIZE, compData, compDataLength);
+ int length = sinflate(data, MAX_DECOMPRESSION_SIZE, compData, compDataSize);
unsigned char *temp = RL_REALLOC(data, length);
if (temp != NULL) data = temp;
else TRACELOG(LOG_WARNING, "SYSTEM: Failed to re-allocate required decompression memory");
- *dataLength = length;
+ *dataSize = length;
- TraceLog(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataLength, *dataLength);
+ TraceLog(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataSize, *dataSize);
#endif
return data;
}
// Encode data to Base64 string
-char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength)
+char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize)
{
static const unsigned char base64encodeTable[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
@@ -3239,17 +3239,17 @@ char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLen
static const int modTable[] = { 0, 2, 1 };
- *outputLength = 4*((dataLength + 2)/3);
+ *outputSize = 4*((dataSize + 2)/3);
- char *encodedData = RL_MALLOC(*outputLength);
+ char *encodedData = RL_MALLOC(*outputSize);
if (encodedData == NULL) return NULL;
- for (int i = 0, j = 0; i < dataLength;)
+ for (int i = 0, j = 0; i < dataSize;)
{
- unsigned int octetA = (i < dataLength)? (unsigned char)data[i++] : 0;
- unsigned int octetB = (i < dataLength)? (unsigned char)data[i++] : 0;
- unsigned int octetC = (i < dataLength)? (unsigned char)data[i++] : 0;
+ unsigned int octetA = (i < dataSize)? (unsigned char)data[i++] : 0;
+ unsigned int octetB = (i < dataSize)? (unsigned char)data[i++] : 0;
+ unsigned int octetC = (i < dataSize)? (unsigned char)data[i++] : 0;
unsigned int triple = (octetA << 0x10) + (octetB << 0x08) + octetC;
@@ -3259,13 +3259,13 @@ char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLen
encodedData[j++] = base64encodeTable[(triple >> 0*6) & 0x3F];
}
- for (int i = 0; i < modTable[dataLength%3]; i++) encodedData[*outputLength - 1 - i] = '='; // Padding character
+ for (int i = 0; i < modTable[dataSize%3]; i++) encodedData[*outputSize - 1 - i] = '='; // Padding character
return encodedData;
}
// Decode Base64 string data
-unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength)
+unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize)
{
static const unsigned char base64decodeTable[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -3275,21 +3275,21 @@ unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength)
};
// Get output size of Base64 input data
- int outLength = 0;
+ int outSize = 0;
for (int i = 0; data[4*i] != 0; i++)
{
if (data[4*i + 3] == '=')
{
- if (data[4*i + 2] == '=') outLength += 1;
- else outLength += 2;
+ if (data[4*i + 2] == '=') outSize += 1;
+ else outSize += 2;
}
- else outLength += 3;
+ else outSize += 3;
}
// Allocate memory to store decoded Base64 data
- unsigned char *decodedData = (unsigned char *)RL_MALLOC(outLength);
+ unsigned char *decodedData = (unsigned char *)RL_MALLOC(outSize);
- for (int i = 0; i < outLength/3; i++)
+ for (int i = 0; i < outSize/3; i++)
{
unsigned char a = base64decodeTable[(int)data[4*i]];
unsigned char b = base64decodeTable[(int)data[4*i + 1]];
@@ -3301,24 +3301,24 @@ unsigned char *DecodeDataBase64(const unsigned char *data, int *outputLength)
decodedData[3*i + 2] = (c << 6) | d;
}
- if (outLength%3 == 1)
+ if (outSize%3 == 1)
{
- int n = outLength/3;
+ int n = outSize/3;
unsigned char a = base64decodeTable[(int)data[4*n]];
unsigned char b = base64decodeTable[(int)data[4*n + 1]];
- decodedData[outLength - 1] = (a << 2) | (b >> 4);
+ decodedData[outSize - 1] = (a << 2) | (b >> 4);
}
- else if (outLength%3 == 2)
+ else if (outSize%3 == 2)
{
- int n = outLength/3;
+ int n = outSize/3;
unsigned char a = base64decodeTable[(int)data[4*n]];
unsigned char b = base64decodeTable[(int)data[4*n + 1]];
unsigned char c = base64decodeTable[(int)data[4*n + 2]];
- decodedData[outLength - 2] = (a << 2) | (b >> 4);
- decodedData[outLength - 1] = (b << 4) | (c >> 2);
+ decodedData[outSize - 2] = (a << 2) | (b >> 4);
+ decodedData[outSize - 1] = (b << 4) | (c >> 2);
}
- *outputLength = outLength;
+ *outputSize = outSize;
return decodedData;
}