Skip to content

Commit b465b4e

Browse files
committed
RENAMED: Variable names for consistency, textLength (length in bytes) vs textSize (measure in pixels)
1 parent 2853b28 commit b465b4e

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

src/raudio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,9 +2770,9 @@ static const char *GetFileNameWithoutExt(const char *filePath)
27702770

27712771
if (filePath != NULL) strncpy(fileName, GetFileName(filePath), MAX_FILENAMEWITHOUTEXT_LENGTH - 1); // Get filename with extension
27722772

2773-
int size = (int)strlen(fileName); // Get size in bytes
2773+
int fileNameLength = (int)strlen(fileName); // Get size in bytes
27742774

2775-
for (int i = 0; (i < size) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
2775+
for (int i = 0; (i < fileNameLength) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
27762776
{
27772777
if (fileName[i] == '.')
27782778
{

src/rcore.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,24 +2009,24 @@ bool IsFileExtension(const char *fileName, const char *ext)
20092009

20102010
if (fileExt != NULL)
20112011
{
2012-
int fileExtLen = (int)strlen(fileExt);
2012+
int fileExtLength = (int)strlen(fileExt);
20132013
char fileExtLower[16] = { 0 };
20142014
char *fileExtLowerPtr = fileExtLower;
2015-
for (int i = 0; (i < fileExtLen) && (i < 16); i++)
2015+
for (int i = 0; (i < fileExtLength) && (i < 16); i++)
20162016
{
20172017
// Copy and convert to lower-case
20182018
if ((fileExt[i] >= 'A') && (fileExt[i] <= 'Z')) fileExtLower[i] = fileExt[i] + 32;
20192019
else fileExtLower[i] = fileExt[i];
20202020
}
20212021

20222022
int extCount = 1;
2023-
int extLen = (int)strlen(ext);
2024-
char *extList = (char *)RL_CALLOC(extLen + 1, 1);
2023+
int extLength = (int)strlen(ext);
2024+
char *extList = (char *)RL_CALLOC(extLength + 1, 1);
20252025
char *extListPtrs[MAX_FILE_EXTENSIONS] = { 0 };
2026-
strncpy(extList, ext, extLen);
2026+
strncpy(extList, ext, extLength);
20272027
extListPtrs[0] = extList;
20282028

2029-
for (int i = 0; i < extLen; i++)
2029+
for (int i = 0; i < extLength; i++)
20302030
{
20312031
// Convert to lower-case if extension is upper-case
20322032
if ((extList[i] >= 'A') && (extList[i] <= 'Z')) extList[i] += 32;
@@ -2163,9 +2163,9 @@ const char *GetFileNameWithoutExt(const char *filePath)
21632163
if (filePath != NULL)
21642164
{
21652165
strncpy(fileName, GetFileName(filePath), MAX_FILENAME_LENGTH - 1); // Get filename.ext without path
2166-
int size = (int)strlen(fileName); // Get size in bytes
2166+
int fileNameLenght = (int)strlen(fileName); // Get size in bytes
21672167

2168-
for (int i = size; i > 0; i--) // Reverse search '.'
2168+
for (int i = fileNameLenght; i > 0; i--) // Reverse search '.'
21692169
{
21702170
if (fileName[i] == '.')
21712171
{
@@ -2232,11 +2232,11 @@ const char *GetPrevDirectoryPath(const char *dirPath)
22322232
{
22332233
static char prevDirPath[MAX_FILEPATH_LENGTH] = { 0 };
22342234
memset(prevDirPath, 0, MAX_FILEPATH_LENGTH);
2235-
int pathLen = (int)strlen(dirPath);
2235+
int dirPathLength = (int)strlen(dirPath);
22362236

2237-
if (pathLen <= 3) strncpy(prevDirPath, dirPath, MAX_FILEPATH_LENGTH - 1);
2237+
if (dirPathLength <= 3) strncpy(prevDirPath, dirPath, MAX_FILEPATH_LENGTH - 1);
22382238

2239-
for (int i = (pathLen - 1); (i >= 0) && (pathLen > 3); i--)
2239+
for (int i = (dirPathLength - 1); (i >= 0) && (dirPathLength > 3); i--)
22402240
{
22412241
if ((dirPath[i] == '\\') || (dirPath[i] == '/'))
22422242
{
@@ -2323,8 +2323,8 @@ const char *GetApplicationDirectory(void)
23232323

23242324
if (_NSGetExecutablePath(appDir, &size) == 0)
23252325
{
2326-
int len = strlen(appDir);
2327-
for (int i = len; i >= 0; --i)
2326+
int appDirLength = (int)strlen(appDir);
2327+
for (int i = appDirLength; i >= 0; --i)
23282328
{
23292329
if (appDir[i] == '/')
23302330
{
@@ -2346,8 +2346,8 @@ const char *GetApplicationDirectory(void)
23462346

23472347
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
23482348
{
2349-
int len = strlen(appDir);
2350-
for (int i = len; i >= 0; --i)
2349+
int appDirLength = (int)strlen(appDir);
2350+
for (int i = appDirLength; i >= 0; --i)
23512351
{
23522352
if (appDir[i] == '/')
23532353
{
@@ -2442,12 +2442,12 @@ int MakeDirectory(const char *dirPath)
24422442
if (DirectoryExists(dirPath)) return 0; // Path already exists (is valid)
24432443

24442444
// Copy path string to avoid modifying original
2445-
int len = (int)strlen(dirPath) + 1;
2446-
char *pathcpy = (char *)RL_CALLOC(len, 1);
2447-
memcpy(pathcpy, dirPath, len);
2445+
int dirPathLength = (int)strlen(dirPath) + 1;
2446+
char *pathcpy = (char *)RL_CALLOC(dirPathLength, 1);
2447+
memcpy(pathcpy, dirPath, dirPathLength);
24482448

24492449
// Iterate over pathcpy, create each subdirectory as needed
2450-
for (int i = 0; (i < len) && (pathcpy[i] != '\0'); i++)
2450+
for (int i = 0; (i < dirPathLength) && (pathcpy[i] != '\0'); i++)
24512451
{
24522452
if (pathcpy[i] == ':') i++;
24532453
else
@@ -2499,10 +2499,10 @@ bool IsFileNameValid(const char *fileName)
24992499

25002500
if ((fileName != NULL) && (fileName[0] != '\0'))
25012501
{
2502-
int length = (int)strlen(fileName);
2502+
int fileNameLength = (int)strlen(fileName);
25032503
bool allPeriods = true;
25042504

2505-
for (int i = 0; i < length; i++)
2505+
for (int i = 0; i < fileNameLength; i++)
25062506
{
25072507
// Check invalid characters
25082508
if ((fileName[i] == '<') ||
@@ -2528,15 +2528,15 @@ bool IsFileNameValid(const char *fileName)
25282528
if (valid)
25292529
{
25302530
// Check invalid DOS names
2531-
if (length >= 3)
2531+
if (fileNameLength >= 3)
25322532
{
25332533
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'N')) || // CON
25342534
((fileName[0] == 'P') && (fileName[1] == 'R') && (fileName[2] == 'N')) || // PRN
25352535
((fileName[0] == 'A') && (fileName[1] == 'U') && (fileName[2] == 'X')) || // AUX
25362536
((fileName[0] == 'N') && (fileName[1] == 'U') && (fileName[2] == 'L'))) valid = false; // NUL
25372537
}
25382538
2539-
if (length >= 4)
2539+
if (fileNameLength >= 4)
25402540
{
25412541
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'M') && ((fileName[3] >= '0') && (fileName[3] <= '9'))) || // COM0-9
25422542
((fileName[0] == 'L') && (fileName[1] == 'P') && (fileName[2] == 'T') && ((fileName[3] >= '0') && (fileName[3] <= '9')))) valid = false; // LPT0-9

src/rlgl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,12 +2496,12 @@ void rlLoadExtensions(void *loader)
24962496
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
24972497

24982498
// NOTE: We have to duplicate string because glGetString() returns a const string
2499-
int extSize = (int)strlen(extensions); // Get extensions string size in bytes
2500-
char *extensionsDup = (char *)RL_CALLOC(extSize + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
2501-
strncpy(extensionsDup, extensions, extSize);
2499+
int extensionsLength = (int)strlen(extensions); // Get extensions string size in bytes
2500+
char *extensionsDup = (char *)RL_CALLOC(extensionsLength + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
2501+
strncpy(extensionsDup, extensions, extensionsLength);
25022502
extList[numExt] = extensionsDup;
25032503

2504-
for (int i = 0; i < extSize; i++)
2504+
for (int i = 0; i < extensionsLength; i++)
25052505
{
25062506
if (extensionsDup[i] == ' ')
25072507
{

src/rtext.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,17 +1449,17 @@ char **LoadTextLines(const char *text, int *count)
14491449

14501450
if (text != NULL)
14511451
{
1452-
int textSize = TextLength(text);
1452+
int textLength = TextLength(text);
14531453
lineCount = 1;
14541454

14551455
// First text scan pass to get required line count
1456-
for (int i = 0; i < textSize; i++)
1456+
for (int i = 0; i < textLength; i++)
14571457
{
14581458
if (text[i] == '\n') lineCount++;
14591459
}
14601460

14611461
lines = (char **)RL_CALLOC(lineCount, sizeof(char *));
1462-
for (int i = 0, l = 0, lineLen = 0; i <= textSize; i++)
1462+
for (int i = 0, l = 0, lineLen = 0; i <= textLength; i++)
14631463
{
14641464
if ((text[i] == '\n') || (text[i] == '\0'))
14651465
{

src/rtextures.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
14881488
#if defined(SUPPORT_MODULE_RTEXT)
14891489
if (text == NULL) return imText;
14901490

1491-
int size = (int)strlen(text); // Get size in bytes of text
1491+
int textLength = (int)strlen(text); // Get length of text in bytes
14921492
int textOffsetX = 0; // Image drawing position X
14931493
int textOffsetY = 0; // Offset between lines (on linebreak '\n')
14941494

@@ -1499,7 +1499,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
14991499
// Create image to store text
15001500
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
15011501

1502-
for (int i = 0; i < size;)
1502+
for (int i = 0; i < textLength;)
15031503
{
15041504
// Get next codepoint from byte string and glyph index in font
15051505
int codepointByteCount = 0;

src/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ void TraceLog(int logType, const char *text, ...)
142142
default: break;
143143
}
144144

145-
unsigned int textSize = (unsigned int)strlen(text);
146-
memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
145+
unsigned int textLength = (unsigned int)strlen(text);
146+
memcpy(buffer + strlen(buffer), text, (textLength < (MAX_TRACELOG_MSG_LENGTH - 12))? textLength : (MAX_TRACELOG_MSG_LENGTH - 12));
147147
strcat(buffer, "\n");
148148
vprintf(buffer, args);
149149
fflush(stdout);

0 commit comments

Comments
 (0)