removed unused sizeof

fixing my recent mistakes
This commit is contained in:
Václav Šmejkal 2022-05-24 18:03:08 +02:00
parent cea8f06ad8
commit 70a2040bab
3 changed files with 10 additions and 10 deletions

View File

@ -33,16 +33,16 @@ outputFlags decryptText(char *text, char *key, inputFlags flags)
}
//SET LENGTH (numberBuffer)
returningText = malloc(sizeof(char) * numberBuffer);
textKeyChain = malloc(sizeof(int) * numberBuffer);
int encryptedTextKeyChain[sizeof(int) * numberBuffer];
returningText = malloc(numberBuffer);
textKeyChain = malloc(numberBuffer);
int encryptedTextKeyChain[numberBuffer];
textKeyChainLength = numberBuffer;
//LOAD textKeyChain
generateTextKeyChain(key, textKeyChain, numberBuffer);
//LOAD encryptedTextKeyChain
for (int i = 0; i < (sizeof(encryptedTextKeyChain) / sizeof(int)); i++)
for (int i = 0; i < sizeof(encryptedTextKeyChain) / sizeof(int); i++)
{
numberBuffer = 0;
@ -54,7 +54,7 @@ outputFlags decryptText(char *text, char *key, inputFlags flags)
numberBuffer++;
}
textBuffer = malloc(sizeof(char) * numberBuffer);
textBuffer = malloc(numberBuffer);
//LOAD textBuffer
for (int j = 0; j < strlen(text); j++)

View File

@ -14,10 +14,10 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
if (!flags.skipCheck) checkVersion(flags);
//VARIABLES
char *key = malloc(sizeof(char) * getKeyLength());
char *key = malloc(getKeyLength());
char *returningText;
char *textBuffer;
int *textKeyChain = malloc(sizeof(int) * strlen(text));
int *textKeyChain = malloc(strlen(text));
int numberBuffer;
FILE *fileBuffer;
@ -78,13 +78,13 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
}
//ALLOCATE returningText (WITH THE SEPARATORS)
returningText = malloc(sizeof(char) * numberBuffer + strlen(text) - 1);
returningText = malloc(numberBuffer + strlen(text) - 1);
strcpy(returningText, "");
//LOAD returningText
for (int i = 0; i < strlen(text); i++)
{
numberBuffer = sizeof(int) * countIntLength(textKeyChain[i]);
numberBuffer = countIntLength(textKeyChain[i]);
if (i != 0)
{

View File

@ -59,7 +59,7 @@ void checkVersion(inputFlags flags)
//COUNT LENGTH OF buffer
fileBuffer = fopen(VERSIONS_NAME, "r");
fseek(fileBuffer, 0, SEEK_END);
buffer = malloc(sizeof(char) * ftell(fileBuffer));
buffer = malloc(ftell(fileBuffer));
fclose(fileBuffer);
//SET fileBuffer